Environment
OS : MacOS 10.15.7
CocosCreator : 3.3.1
We want to use a build template to exclude certain assets from the build result.
The code to exclude specific assets is implemented in hooks.ts which is generated when the build template is deployed.
If we delete the corresponding file in the onBeforeBuild() method of hooks.ts, the build will stop midway.
From the error message, I found out that it was trying to read the information of the deleted file from under project/lib/.
This method worked in v3.1.0, but it no longer works in v3.3.1.
Here are the steps to reproduce it.
Translated with www.DeepL.com/Translator (free version)
・Introduce the build template from the menu.
[Project] > [Generate Builder Extention]
・Enable cocos-build-temprate.
[Extention] > [Extention Manager]
・Modify generated project/extensions/cocos-build-template/source/hooks.ts to delete specific files in onBeforeBuild().
export async function onBeforeBuild(options: ITaskOptions) {
const srcPath = `${Editor.Project.path}/assets/CheckScene.scene`;
const srcMetaPath = `${Editor.Project.path}/assets/CheckScene.meta`;
fs.unlinkSync(srcPath);
fs.unlinkSync(srcMetaPath);
}
・Compile hooks.ts with npx tsc.
$ pwd
$ ...project/extensions/cocos-build-template/
# npx tsc
・Build the project from the console.
/Applications/CocosCreator/Creator/3.3.1/CocosCreator.app/Contents/MacOS/CocosCreator --project …/build-template-test/project --build “configPath=…/build-template-test/buildConfig_web-desktop.json;”
・The following error is output.
2021-10-15 12:53-error: {"errno":-2,"code":"ENOENT","syscall":"open","path":"...build-template-test/project/library/a9/a90df829-593d-42d3-af14-114e7652f3f8.json"}
2021-10-15 12:53-debug: ENOENT: no such file or directory, open '...build-template-test/project/library/a9/a90df829-593d-42d3-af14-114e7652f3f8.json'10%
The error a90df829-593d-42d3-af14-114e7652f3f8.json was the meta-information of CheckScene.scene.