question
When HBuiderX runs the applet, it has checked whether to compress the code at runtime, but the code is not compressed. After subpackaging, it was found that the code was subpackaged but the compression problem was not resolved.
compromise
The code can be set to adjust the size of the development preview to 4m to solve the editing problem, but the file is too large to preview and preview on the real machine.
hubuiberX can't compress the uploaded code, and the WeChat platform can also use the publishing mode of hubuiberX to compress the solution.
new question
Although using a compromise method can solve some problems, if the file is not compressed in the dev development mode, the vendor.js file will be too large, and eventually hubuiberX will report an error when running a certain page component, resulting in the code being unable to be hot updated and the program unable to write down.
Fix hubuiderX runtime
manifest.json Application configuration WeChat part
manifest.json configuration file
Manually add
"optimization": { "subPackages": true //whether to enable subpackage optimization } Re-run the code and find that it can be compressed
This may be a bug in hubuiberX
不过设置了这个 还是只能压缩主包的 vendor.js文件 分包也会生成vendor.js文件 但是分包的 vendor.js没有进行压缩!
"mp-weixin": {
"optimization": {
"subPackages": true //是否开启分包优化
},
"setting": {
"urlCheck": false, //是否检查安全域名和 TLS 版本
"minified": true, //上传代码时是否自动压缩
"postcss": true //上传代码时样式是否自动补全
},
Solve vuecli runtime
Use the vuecli terminal to configure 解决 hubuiderX运行时
the content first.
When running the program yarn run dev:mp-weixin, add the --minimize parameter after the script to be run.
The project created by cli can add the parameter --minimize in package.json, for example:
"dev:mp-weixin": "cross-env NODE_ENV=development UNI_PLATFORM=mp-weixin vue-cli-service uni-build --watch --minimize"