Assume that the file structure in the root directory is as follows:
|— ascf.config.json
|— app.json
|— app.js
|— app.css
|— components
| |— cart.json
| |— cart.hxml
| |— cart.js
| |— cart.css
|— pages
| |— user
| | |— user.json
| | |— user.hxml
| | |— user.js
| | |— user.css
|— pkgA
| |— pageA1
| | |— user.json
| | |— user.hxml
| | |— user.js
| | |— user.css
Declare the project's subpackage structure using the subpackages field in app.json:
"subpackages": [
{
"root": "pkgA",
"pages": [
"pageA1/user"
]
}
], Rules for converting a mini program into an atomic service:
- Copy the root field from the app.json file and rename resource to the underscore format for naming subpackages.
- In the rawfile of each subpackage, retain the directory structure in root.
Packaging Principle
- After subpackages are declared, resource within the paths specified by subpackages are packaged, while resources within all other paths are packaged into the main package.
- The main package can also contain its own pages. During packaging, pages in the main package are allocated into corresponding subpackages based on the path rules. Pages not specified by subpackages are retained in the main package.
- The root directory of a subpackage cannot be a subdirectory of another subpackage.
- Resource dependency is not allowed between subpackages. Subpackages can depend on resources of the main package, but the main package cannot depend on subpackage resources.
- The tabbar page must be stored in the main package.