这是我的Webpack.config.js.It在其他项目中运行正常但是当我在这个项目中复制相同的配置时它给了我上面的错误。经过一些研究后我发现 loader 将字符串作为输入,加载程序将数组作为输入,这应该是一个问题,但我认为我的代码中没有这个问题.Please gude
const postcssPlugins = [
require('postcss-cssnext')(),
require('postcss-modules-values')
];
const scssLoader = [
{ loader: 'style-loader' },
{ loader: 'css-loader' },
{ loader: 'sass-loader' }
];
const postcssLoader = [
{ loader: 'style-loader' },
{ loader: 'css-loader', options: { modules: true } },
{ loader: 'postcss-loader', options: { plugins: () => [...postcssPlugins] } }
];
var path = require('path');
module.exports = {
entry: './src/main/resources/static/js/app.js',
output: {
path: __dirname + '/src/main/resources/static/js',
filename: 'bundle.js'
},
module: {
loaders: [
{
test: /\.jsx?$/,
exclude: /node_modules/,
loader: 'babel-loader',
query: {
presets: ['es2015', 'react']
}
},
{
test: /\.(scss|sass)$/,
loader: scssLoader,
include: [__dirname]
},
{ test: /\.css$/,
loader: postcssLoader,
include: [__dirname]
}
]
}
};