How to solve the problem that the vendor.js file is too large after uni-app compilation
This article mainly explains "how to solve the problem that the vendor.js file is too large after uni-app compilation". The explanation in this article is simple and clear, easy to learn and understand. Please follow the idea of Xiaobian and go deep into it slowly to study and learn "how to solve the problem that the vendor.js file is too large after uni-app compilation" together!
uni-app compiled vendor.js file too large foreground
Weixin Mini Programs (Mini) developed with uni-app, tool prompt vendor.js is too large when released, es6 to es5 conversion has been skipped. After checking it, I found that common/vendor.js in the compiled code has exceeded 500k, so volume control is needed.
HBuilderX created items check Run-> Run to Mini programs Simulator-> Do you compress code when running
For projects created with cli, you can add the parameter-minimize in pacakge.json, for example: "dev:mp-weixin": "cross-env NODE_ENV=development UNI_PLATFORM=mp-weixin vue-cli-service uni-build --watch --minimize"
Found after running
The vendor.js file was reduced to over 200 k.
Mini programs subcontracting vendor or too large
After using subcontracting, you will find a strange problem. The components and js files of the child package will be packaged into the vendor.js file of the main package, which will cause the vendor.js to be too large and cause the main package to exceed 2M.
Open manifest.json-> source view-> mp-weixin node
Add the following code "optimization": { "subPackages": true}
You will find that the js file of the subcontract will no longer be packaged into the vendor.js of the main package, and the pro-test will work.
Thank you for reading, the above is "uni-app compiled vendor.js file is too large how to solve" the content, after the study of this article, I believe that we have a deeper understanding of uni-app compiled vendor.js file is too large how to solve this problem, the specific use of the situation also needs to be verified by practice. Here is, Xiaobian will push more articles related to knowledge points for everyone, welcome to pay attention!