[ad_1]
Hi, im korean develper.
I made a javascript file primarily based on nodejs for comfort of growth. It can also be within the asset folder and can’t be rerouted on account of private causes.
My drawback is, this js file doesn’t must be included within the construct, nevertheless it tries to be included within the construct and causes an error. Is there a solution to exclude the javascript file within the asset folder from the construct?
Hi, you possibly can attempt to wrap up your js code in defines as you wanted
if (!CC_BUILD) {
// your js code right here
}
I don’t need to modify the code, since there’s no half that calls the js file, I need to ignore it within the construct.
Then you would modify a construct course of by way of an editor extension that it’s essential to create.
I agree with you, I used to be already engaged on the method
// hooks.ts
import * as fs from 'fs';
operate moveFile(from: string, to: string) {
console.log('from : ' + from + ', to : ' + to);
let dirTemp = to.break up('');
dirTemp.pop();
let dir = dirTemp.be a part of('');
!fs.existsSync(dir) && fs.mkdirSync(dir);
fs.copyFileSync(from, to);
fs.unlinkSync(from);
}
export async operate onBeforeBuild(choices) {
let pack = choices['packages'] || {};
let module = pack['build-ignore-files'] || {};
let listing = (module['ignoreList'] || '').break up(';');
for (let i = listing.size - 1; i >= 0; i--) {
listing.push(listing[i] + '.meta');
}
for (let path of listing) {
console.log(path + ' is exist : ' + fs.existsSync(path).toString());
if (path === '' || !fs.existsSync(path)) {
proceed;
}
moveFile(path, Editor.Project.path + '' + path.break up('').pop());
}
}
export async operate onAfterBuildAssets(choices) {
console.log('after_build');
let pack = choices['packages'] || {};
let module = pack['build-ignore-files'] || {};
let listing = (module['ignoreList'] || '').break up(';');
for (let i = listing.size - 1; i >= 0; i--) {
listing.push(listing[i] + '.meta');
}
for (let path of listing) {
let tempPath = Editor.Project.path + '' + path.break up('').pop();
if (tempPath === '' || !fs.existsSync(tempPath)) {
proceed;
}
moveFile(tempPath, path);
}
}
export operate load() {
console.log('build-ignore-files load');
}
export operate unload() {
console.log('build-ignore-files unload');
}
This is my code.
Also, should you proceed with the construct, the file shall be deleted
However, there appears to be an issue with asset db. The file has been erased, however it’s nonetheless about to be included within the construct
What ought to i do?
appears it’s essential to refresh/replace belongings db, most likely is best delete file by way of assets-db API straight as an alternative of FileSystem API.
I additionally thought-about that, however I’m utilizing Cocos model 3.6 and I don’t have Editor.assetdb in 3.6 How can I exploit the assetdb?
there’s new Message system might enable you to i assume.
https://docs.cocos.com/creator/guide/en/editor/extension/bundle.html
[ad_2]