Mini program project configurations
With this topic, you can learn to use the mini.project.json
file in the root directory to configure the mini program project.
Overview
In addition to app
and page
, the mini program framework also includes project
to describe the whole mini program project. For more information, refer to Framework overview.
The project
refers to the mini.project.json
file that must be placed in the root directory of the mini program project. You can use the mini.project.json
file to configure advanced features, as listed in the table below.
Features
The following table lists the configuration features of the mini program project:
Field Name | Data Type | Description |
miniprogramRoot | Path String | Specifies the relative path of the mini program source code (the directory where the |
component2 | Boolean | Whether to enable custom components. To enable custom components, check Enable component2 compile in the Details > Project configuration of the IDE. For more information, refer to Custom component introduction. |
axmlStrictCheck | Boolean | Whether to enable axml strict syntax check. Once enabled, it can detect the error of unclosed tags and more. To enable axml strict syntax check, check Enable Strick Axml Check in the Details > Project configuration of the IDE. |
enableHMR | Boolean | Whether to enable simulator hot update. |
enableNodeModuleBabelTransform | Boolean | Whether to enable es6 syntax transformation. |
exclude | Array[String] | The file or file folder to exclude when building package. It follows Glob syntax. For more information, see exclude package blacklist. |
exclude
package blacklist
When you upload a mini program to Mini Program Platform, the local source codes will be packaged and uploaded to the cloud for building. In addition to the above files, the source code package also includes the following contents:
- Mini program source code files:
.acss
.axml
.js
.json
.sjs
- Dependency packages in the
node_modules
directory
When uploading, if the source code package is still too large after compression, network timeout may be triggered. To resolve this error, you can add unnecessary files that are built on the cloud to the exclude
blacklist. For example, if you precompile the code through src
-> dist
, you need to exclude the files in the src
directory and the devDependencies
tool in the node_modules
directory when you upload the mini program.
The following sample code indicates that the source code package excludes the files in the src
and node_modules
directories under the root directory of the project:
"exclude": [
"src/**",
"node_modules/**"
]