一次create-react-app创建项目升级webpack的流水账
栏目: JavaScript · 发布时间: 6年前
内容简介:不再赘述为什么要升级webpack4,有兴趣的小伙伴可以看一下下面撸起袖子开干:克隆项目,新建分支
不再赘述为什么要升级webpack4,有兴趣的小伙伴可以看一下 知乎:如何评价webpack4
下面撸起袖子开干:
克隆项目,新建分支
git checkout -b feature_webpack_upgrade # 相当于以下两句的简写 git branch feature_webpack_upgrade git checkout feature_webpack_upgrade
升级 webpack
yarn 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 function
这个问题比较棘手,继续google之后找到原因 missingDeps.some not a function
yarn add react-dev-utils@6.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 instead mini-css-extract-plugin
很明显, Entrypoint
由 mini-css-extract-plugin
提供了,查找之下发现 Chunk.entrypoints
由 extract-text-webpack-plugin
提供,那么:
yarn remove extract-text-webpack-plugin yarn add mini-css-extract-plugin
继续运行,报错:
Error: Chunk.initial was removed. Use canBeInitial/isOnlyInitial()
升级 webpack-manifest-plugin
即可。
运行通过,提交代码,PR。
所有问题都可以通过仔细阅读 error trace
加上善用google搞定。
收工~
以上所述就是小编给大家介绍的《一次create-react-app创建项目升级webpack的流水账》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!
猜你喜欢:- 关于最近的流水账
- 殷浩详解 DDD:如何避免写流水账代码?
- thinkphp 5.0-5.1 命令执行流水账记录
- DevOps 测试流水线
- 流水不腐,户枢不蠹
- Hiredis 实现 Redis 流水线
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
Django 1.0 Template Development
Scott Newman / Packt / 2008 / 24.99
Django is a high-level Python web application framework designed to support the rapid development of dynamic websites, web applications, and web services. Getting the most out of its template system a......一起来看看 《Django 1.0 Template Development》 这本书的介绍吧!