Custom Project Build Process
Custom Project Build Template
Cocos Creator supports custom build templates for each project. Add a
build-templates folder to the project path, divide the sub-folder according to the
platform path. Then all the files in this folder will be automatically copied to the build generated project according to the corresponding folder structure after the build. Currently, all platforms except the native platform support this function, the specific platform name can be referred to the following custom build template platform support table.
If the current platform is
build-templates/web-mobile/index.html will be copied to
In addition to this, build templates can be customized in the following ways.
Since the content of the package is not guaranteed to be exactly the same in every version, when the build template within the editor is updated, the developer also needs to update the build template within their project. Now add a new way to use the template, click on Project -> Create preview template in the main menu, and an
ejs template file will be generated for the corresponding platform.
Parameters are imported into these templates during the build, and content that is frequently changed during the build is placed in sub-templates of that template. You only need to modify what you want to use, so that the build templates within the project can be updated less frequently.
Note: the copy template occurs after the rendered template. For example, if both
index.htmlexist in this directory, the final packaged package will be the
index.htmlfile instead of the
Many mini games have their own configuration
JSON files, like
game.json to WeChat Mini Games. Files in the build templates folder will just copy in default, but this configuration JSON will be merged instead of overwrite. Of course, it doesn't mean that all
JSON file will be merged, you can check it in the tables below.
Custom build template platform supports tables
JSON files corresponding to the data fusion for each mini game are as follows:
|Custom Build Template
|WeChat Mini Game
|Xiaomi Quick Game
|Huawei Quick Game
|Use the Build Panel's
|Baidu Mini Game
|OPPO Mini Game
|vivo Mini Game
|Alipay Mini Game
|X (Not recommended)
Custom Build Plugins
It is currently in the internal testing phase and is not open to the public at this time.