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

按照webpack的指南,敲的demo中用到CommonsChunkPlugin这个插件,报如下错误:

指南上的用法:

    plugins: [
      new HTMLWebpackPlugin({
        title: ‘Code Splitting‘
       }),
+     new webpack.optimize.CommonsChunkPlugin({
+       name: ‘common‘ // 指定公共 bundle 的名称。
+     })
    ],

解决方法:

    plugins: [
      new HTMLWebpackPlugin({
        title: ‘Code Splitting‘
       }),
-     new webpack.optimize.CommonsChunkPlugin({
-       name: ‘common‘ // 指定公共 bundle 的名称。
-     })
    ],
+  optimization: {
+    splitChunks: {
+        cacheGroups: {
+        commoms: {
+            name: ‘commons‘,
+            chunks: ‘initial‘,
+            minChunks: 2
+        }
+        }
+    }
+   }

原文地址:https://www.cnblogs.com/hongyan90/p/12487473.html

时间: 2024-11-08 12:49:32

Error: webpack.optimize.CommonsChunkPlugin has been removed, please use config.optimization.splitChunks instead.的相关文章

迁移到webpack4:从webpack.optimize.CommonsChunkPlugin到config.optimization.splitChunk,以及有个搜出来的中文解决办法是错的

webpack4 Error: webpack.optimize.CommonsChunkPlugin has been removed, please use config.optimization.splitChunks instead 哦,原来是原来的插件不能用了,这个中文指南,标的是webpack4.7.0,结果这块都没更新啊...于是必应搜了一下,第一个出来的是这个 webpack4 Error: webpack.optimize.CommonsChunkPlugin has been

ERROR: Failed to load /usr/local/ERL_LIBS_FILE/esdl/rebar.config

***ERROR:Could not find sdl-config ERROR: Failed to load /usr/local/ERL_LIBS_FILE/esdl/rebar.config: {error, {228,file, {throw, error, [{erl_eval, do_apply, 5}, erl_eval, expr,5}, erl_eval, exprs, 5}, {erl_eval, expr,5}, {file, eval_stream2, 6}, {fil

Error configuring application listener of class com.sun.faces.config.ConfigureListener

错误信息如下: 严重: Error configuring application listener of class com.sun.faces.config.ConfigureListener java.lang.NoClassDefFoundError: javax/faces/event/SystemEventListener 个人删掉下面这两个包后,错误就没了: jsf-api.jar jsf-impl.jar

AndroidStudio编译error:app:validateReleaseSigning'Keystore file not found for signing config 'release

使用AndroidStudio编译时提示error: Error:Execution failed for task ':app:validateReleaseSigning'. > Keystore file not found for signing config 'release'. 从字面意思可以看出是要打发布包缺少keystore签名文件,只需要把build.gradle里的一段代码注释掉即可,当然别忘了打发布包时取消注释. signingConfigs { release { sto

webpack错误Chunk.entry was removed. Use hasRuntime()

这个错误在从webpack1升级webpack2或webpack3时候都遇到了,起初查到的都是extract-text-webpack-plugin版本的问题,升级了还是不管用.搜索引擎上查不到其他的说法, 笨的不知道该怎么办了.后来从github的issue上查到了问题所在,是另一个plugin chunk-manifest-webpack-plugin不兼容造成的,将其升级到最新版就行了. 这里要提一句,使用了小众搜索这个搜索引擎,码农专用,别用某度,不行的. 参考:https://gith

记一次webpack3升级webpack4的踩坑

webpack4版本也出了很久了 之前弄过一段时间的升级 后面因为种种原因搁浅了 今天有硬着头皮升级了一波 yeah 还好升级成功了 先贴一波原先webpack3的github配置 ps(我只是一个菜鸡= = webpack的配置很辣鸡 )废话少说 开撸 1 webpack升级到4.0版本并且安装webpack-cli yarn add webpack-cli globalyarn add webpack-cli -D 如果不对webpack-cli进行安装的话会报错 如下: The CLI m

[Webpack 2] Grouping vendor files with the Webpack CommonsChunkPlugin

Often, you have dependencies which you rarely change. In these cases, you can leverage the CommonsChunkPlugin to automatically put these modules in a separate bundled file so they can be cached and loaded separately from the rest of your code (levera

[Webpack 2] Chunking common modules from multiple apps with the Webpack CommonsChunkPlugin

If you have a multi-page application (as opposed to a single page app), you’re likely sharing modules between these pages. By chunking these common modules into a single common bundle, you can leverage the browser cache much more powerfully. In this

基于CommonsChunkPlugin,webpack打包优化

前段时间一直在基于webpack进行前端资源包的瘦身.在项目中基于路由进行代码分离,http://www.cnblogs.com/legu/p/7251562.html.但是打包的文件还是很大,特别是通过CommonsChunkPlugin的async:true打包的chunk的公共包不可控.今天就通过CommonsChunkPlugin插件的理解,来优化这个问题 问题描述详细些,我们的打包是基于router进行的chunk分割,比如router有10个,router1,router2用到了ec