我正在使用webpack来构建我的反应组件,我正在尝试使用extract-text-webpack-plugin它将我的css与生成的js文件分开.但是,当我尝试构建组件时,我收到以下错误:
Module build failed: ReferenceError: window is not defined.
我的webpack.config.js文件如下所示:
var webpack = require('webpack');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
module.exports = {
entry: {
MainComponent: './src/main.js'
},
output: {
libraryTarget: 'var',
library: 'MainComponent',
path: './build',
filename: '[name].js'
},
module: {
loaders: [{
test: /\.css$/, loader: ExtractTextPlugin.extract('style-loader!css-loader')
}]
},
plugins: [
new ExtractTextPlugin('styles.css')
]
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 React 连接 Jest 测试,并且我已将Using Jest with React Tutorial 中的所有内容复制并粘贴到演示项目中,并且我收到一个 TypeError,提示某些对象中node_modules/react/lib/ReactUpdates.js没有该功能getPooled()。据我所知,这是在文件var React = require('react/addons')内部发生的CheckboxWithLabel-test.js。我觉得这是一件非常简单的事情,我只是忽略了但我找不到任何东西。