Error:webpack.optimize.CommonsChunkPlugin has been removed

created at 07-05-2021 views: 26

description

error message:

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

solution

build/webpack.base.conf.js file
Add the following code, which is equal to resolve and output

optimization: {
  splitChunks: {
    cacheGroups: {
      commons: {
        name: 'commons',
        chunks: 'initial',
        minChunks: 2
      }
    }
  }
}

Comment a line of code: new webpack.optimize.CommonsChunkPlugin('common.js')

plugins: [
  // new webpack.optimize.CommonsChunkPlugin('common.js'),
  new webpack.ProvidePlugin({
    $:"jquery",
    jQuery:"jquery"
  })
]
created at:07-05-2021
edited at: 07-05-2021: