解决The code generator has deoptimised the styling of xxxx.js as it exceeds the max of 500kb
1.需求背景
- 最近在vue项目引用了一个js文件,由于这个文件的大小超过了500kb,因此在打包的时候抛了一个错:
The code generator has deoptimised the styling of xxxx.js as it exceeds the max of 500kb
。
解决方案
-
这个问题其实就是babel处理文件的大小被限制在了500kb,解决如下:
-
// 在项目根目录下查找 .babelrc 或 babel.config.js 文件,如果没有就创建一个(两者其一即可),配置如下: // .babelrc: { "compact": false } // babel.config.js: module.exports = { compact: false, }
-
解决。