How to solve the problem that the package size of the applet is too large?

.Currently, subcontracting of mini programs has the following restrictions:

  • The size of all subpackages of the entire applet should not exceed 20M
  • The size of a single subpackage/main package does not exceed 2M

Original project path:

├── app.js
├── app.json
├── app.wxss
├── packageA
│   └── pages
│       ├── cat
│       └── dog
├── packageB
│   └── pages
│       ├── apple
│       └── banana
├── pages
│   ├── index
│   └── logs
└── utils

Subpackage loading of applets

Subpackage configuration path

├── app.js
├── app.json
├── app.wxss
├── packageA
│   └── pages
│       ├── cat
│       └── dog
├── packageB
│   └── pages
│       ├── apple
│       └── banana
├── pages
│   ├── index
│   └── logs
└── utils

Packaging Principles

  • After declaration  subpackages , it will  subpackages be packaged according to the configuration path, and subpackages directories outside the configuration path will be packaged into the main package
  • The main package can also have its own pages, the outermost pages field.
  • subpackagesubpackage The root directory of a cannot be a subdirectory within  another 
  • tabBar The page must be inside the main package

Citation principle

  • packageA JS files cannot be required  , but  JS files within  packageB the main package can be required ;  this restriction is not imposed when using subpackage asynchronizationpackageA
  • packageA The template cannot be imported  packageB , but packageA the template in the main package can be required
  • packageA unusable  packageB resources, but can use packageA resources inside the main package,

Low version compatible

The compatibility of the old version of the client is handled by the WeChat background compilation. The background will compile two code packages, one is the code after subcontracting, and the other is the compatible code of the entire package. New clients use subpackages, while old clients still use the whole package. The full package will put  subpackage the paths inside each page into pages.

For details, see : Use Subcontract | WeChat Open Documentation

Guess you like

Origin blog.csdn.net/m0_69644606/article/details/128054833