webpack 代碼分離

報錯信息:javascript

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


問題緣由:webpack 4版本廢棄了 webpack.optimize.CommonsChunkPlugin, 可是中文網應用了該代碼, 致使出錯java


解決辦法:在webpack.config.js配置文件中 添加webpack

optimization: { //   與  同一級別
    splitChunks: {
      cacheGroups: {
        commons: {
          name: "commons",
          chunks: "initial",
          minChunks: 2
        }
      }
    }
  }optimizationentry、plugins
相關文章
相關標籤/搜索