报错信息
Error: webpack.optimize.CommonsChunkPlugin has been removed, please use config.optimization.splitChunks instead.
原因: webpack 4 版本应该是 废弃了 webpack.optimize.CommonsChunkPlugin
, 但是中文网应用了该代码, 导致出错
解决: 在 webpack.common.js
或者 webpack.config.js
添加
// ...
optimization: {
splitChunks: {
cacheGroups: {
commons: {
name: "commons",
chunks: "initial",
minChunks: 2
}
}
}
}
// ...
注意: optimization
是与 entry
同一级别的
网友评论