webpack.optimize.CommonsChunkPlugin has been removed, please use config.optimization.splitChunks in

根本原因:

是项目在升级了webpack到v4.0.0后,打包生产环境文件,报错走不下去。
CommonsChunkPlugin主要是用来提取第三方库和公共模块,避免首屏加载的bundle文件或者按需加载的bundle文件体积过大,从而导致加载时间过长,着实是优化的一把利器。

   解决办法

  1. build/webpack.base.conf.js文件,增加如下代码,与resolve,output平级
optimization: {
  splitChunks: {
    cacheGroups: {
      commons: {
        name: 'commons',
        chunks: 'initial',
        minChunks: 2
      }
    }
  }
}

2.注释一行代码:new webpack.optimize.CommonsChunkPlugin('common.js')

plugins: [
  // new webpack.optimize.CommonsChunkPlugin('common.js'),
  new webpack.ProvidePlugin({
    $:"jquery",
    jQuery:"jquery"
  })
]

转自:https://www.edoou.com/articles/1579673117961699

上一篇:SpringBoot项目报错If you want an embedded database (H2, HSQL or Derby), please put it on the classpath..


下一篇:read命令参数简单说明