这让我很疯狂,真的错过了什么......
我使用的是Webpack 4.6.0和Webpack-cli ^2.1.2,所以都是最新版。
按照文档(https://webpack.js.org/concepts/mode/)的要求,想要用mode来分别配置生产环境和开发环境,但是出现了以下错误:
configuration[0] has an unknown property 'mode'. These properties are valid: object { amd?, bail?, cache?, context?, dependencies?, devServer?, devtool?, entry, externals?, loader?, module?, name?, node?, output?, parallelism?, performance?, plugins?, profile?, recordsInputPath?, recordsOutputPath?, recordsPath?, resolve?, resolveLoader?, stats?, target?, watch?, watchOptions? }
我错过了什么吗 :O?????
module.exports = [
merge(base, {
mode: 'development',
output: {
path: path.resolve(__dirname, './public/assets/development'),
},
}),
merge(base, {
mode: 'production',
output: {
path: path.resolve(__dirname, './public/assets/production'),
filename: '[name].bundle.js',
},
}),
]
rm -rf node_modules; npm install
命令成功解决了问题。 - pzrq