webpack|webpack 代码分离

【webpack|webpack 代码分离】报错信息:

Error: webpack.optimize.CommonsChunkPlugin has been removed, please use config.optimization.splitChunks instead.


问题原因:webpack 4版本废弃了 webpack.optimize.CommonsChunkPlugin, 但是中文网应用了该代码, 导致出错

解决办法:在webpack.config.js配置文件中 添加
optimization: { //optimizationentry、plugins 同一级别 splitChunks: { cacheGroups: { commons: { name: "commons", chunks: "initial", minChunks: 2 } } } }



转载于:https://www.cnblogs.com/tracy-ling/p/10419501.html

    推荐阅读