反応コンポーネントを構築するために webpack を使用しextract-text-webpack-pluginており、生成された js ファイルから css を分離するために を使用しようとしています。ただし、コンポーネントをビルドしようとすると、次のエラーが発生します:
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')
]
}