The code package of the applets can be divided intoOne "main package" and multiple "sub-packages". The pages you need to access and their dependent resource files should be placed in the main package. When the small program is started, you only need to download the main package and start the small program immediately.The total size of all main packages and subpackages cannot exceed 20M, and the size of each package cannot exceed 2M.

1. Configuration method

In the app. JsonsubpackagesField declaration project subcontracting structure: Subpackages configuration description:

field type instructions
root String Subcontract root
name String Subcontract alias,Can be used when subcontracting pre-download
pages StringArray The subcontract page path, as opposed to the subcontract root directory
independent Boolean Is subcontractingIndependent of the subcontract

2. Subcontracting pre-download

The preload subcontract behavior is triggered when entering a page and is controlled by adding a preloadRule configuration to app.json.

In preloadRule, key is the path to the page, and value is the pre-downloaded configuration to enter the page. Each configuration has the following items:

field type The default value instructions
packages StringArray There is no Enter the page after the pre-download subcontractedThe root or the name.APPRepresents the primary package.
network String wifi The options are as follows: all: indicates that the predownload is not limited. Wifi: indicates that the predownload is performed only in wifi mode

The difference between subcontracted predownload and unpredownload: