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.
project-folder |--assets |--build |--build-templates |--web-mobile |--index.html
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.
project-folder |--assets |--build |--build-templates |--web-mobile |--index.ejs
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:
|Platform||Actual Name||Custom Build Template|
|WeChat Mini Game||wechatgame||
|Xiaomi Quick Game||xiaomi-quick-game||
|Huawei Quick Game||huawei-mini-game||Use the Build Panel's|
|Baidu Mini Game||baidu-mini-game||
|OPPO Mini Game||oppo-mini-game||
|vivo Mini Game||vivo-mini-game||
|Alipay Mini Game||alipay-mini-game||
|Native||native||X (Not recommended)|
Custom Build Plugins
It is currently in the internal testing phase and is not open to the public at this time.