我正在使用webpack和React与react-css-modules和scss文件.当我尝试构建它时,每个导入scss文件的文件都会出现错误 -
ERROR in ./app/components/Buttons/Button.scss
Module build failed: ReferenceError: window is not defined
Run Code Online (Sandbox Code Playgroud)
我用谷歌搜索了一整天,没有在哪里!请帮忙!
这是我的webpack设置:
var webpack = require('webpack');
var PROD = (process.env.NODE_ENV === 'production');
var precss = require('precss');
var autoprefixer = require('autoprefixer');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var HTMLWebpackPluginConfig = new HtmlWebpackPlugin({
template: __dirname + '/app/index.html',
filename: 'index.html',
inject: 'body'
});
module.exports = {
entry: [
'./app/index.jsx'
],
output: {
path: __dirname + '/dist',
filename: PROD ? 'bundle.min.js' : 'bundle.js'
},
watchOptions: {
poll: true
}, …Run Code Online (Sandbox Code Playgroud) sass webpack webpack-dev-server css-modules react-css-modules