Recently, I encountered a bottleneck problem in the development of wechat small program. The volume of the main package of wechat small program packaged by uniAPP project just exceeded the required 2M. The first thing I thought of was to delete the code, local pictures and unused components, but the effect was negligible
The size of the package file before compression is enabled:
Looking at the packaged files, among the WXML, JS, CSS and JSON that are packaged in the vue file of a uni project, the size of the JS file alone is much larger than the original vue file. At this time, the packaging logic is to add a lot of logical code needed for packaging on top of the original vue code. Moreover, the original code format has hardly changed, and there are many blank lines, which seems to take up a lot of volume
Find a solution
From the top menu of builderx and builderx, find the Run to Applet option below; There is an option to compress the code at run time. Check it and re-run the project.
After packing effect:
It obviously looks much more comfortable, with the packaging style, and the corresponding file size is less than half of the size before uncompressed.
But the compression code seems to have a problem:
(Currently in my project, compression is not allowed to enter breakpoint, but after compression is turned off, it can enter breakpoint, this does not matter, compression can only be suitable for release or mobile side debugging, a little trouble but little impact)