我正在使用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)