I'm using webpack to build my react components and I'm trying to use the extract-text-webpack-plugin
to separate my css from my generated js file. However, when I attempt to build the component I get the following error:
Module build failed: ReferenceError: window is not defined
.
My webpack.config.js file looks like this:
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')
]
}