文登区做网站的公司,网站平台怎么做的好,重庆网站营销公司,ui设计入门教程不再赘述为什么要升级webpack4#xff0c;有兴趣的小伙伴可以看一下 知乎#xff1a;如何评价webpack4下面撸起袖子开干#xff1a;克隆项目#xff0c;新建分支git checkout -b feature_webpack_upgrade# 相当于以下两句的简写git branch feature_webpack_upgradegit chec…不再赘述为什么要升级webpack4有兴趣的小伙伴可以看一下 知乎如何评价webpack4下面撸起袖子开干克隆项目新建分支git checkout -b feature_webpack_upgrade# 相当于以下两句的简写git branch feature_webpack_upgradegit checkout feature_webpack_upgrade升级 webpackyarn add webpack webpack-dev-server webpack-cli运行后报错Plugin could not be registered at html-webpack-plugin-before-html-processing. Hook was not found.报错信息表示插件 html-webpack-plugin-before-html-processing有问题然而 webpack中并没有这个插件google之后发现 github上有对这个问题的讨论所以升级插件yarn add react-dev-utils html-webpack-plugin修改配置文件交换以下两个插件位置 new HtmlWebpackPlugin({}),new InterpolateHtmlPlugin(env.raw),继续运行报错TypeError: Cannot read property eslint of undefined升级 eslint即可yarn add eslint-loader继续运行报错missingDeps.some not a functionyarn add react-dev-utils6.0.0-next.3e165448继续运行报错Error: webpack.optimize.UglifyJsPlugin has been removed, please use config.optimization.minimize instead.干掉被移除的插件 UglifyJsPlugin即可 webpack4生产模式下原生支持代码压缩和分割继续运行报错Chunk.entrypoints: Use Chunks.groupsIterable and filter by instanceof Entrypoint insteadmini-css-extract-plugin很明显 Entrypoint由 mini-css-extract-plugin提供了查找之下发现 Chunk.entrypoints由 extract-text-webpack-plugin提供那么yarn remove extract-text-webpack-pluginyarn add mini-css-extract-plugin继续运行报错Error: Chunk.initial was removed. Use canBeInitial/isOnlyInitial()升级 webpack-manifest-plugin即可。运行通过提交代码PR。所有问题都可以通过仔细阅读 error trace加上善用google搞定。收工~