[ad_1]
Hi, im korean develper.
I made a javascript file primarily based on nodejs for comfort of growth. It can be within the asset folder and can’t be rerouted resulting from private causes.
My downside 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 method to exclude the javascript file within the asset folder from the construct?
Hi, you’ll be able to attempt to wrap up your js code in defines as you wanted
if (!CC_BUILD) {
// your js code right here
}
I don’t wish to modify the code, since there’s no half that calls the js file, I wish to ignore it within the construct.
Then you may modify a construct course of by way of an editor extension that you could create.
I agree with you, I used to be already engaged on the method
// hooks.ts
import * as fs from 'fs';
perform 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 perform 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 perform 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 perform load() {
console.log('build-ignore-files load');
}
export perform unload() {
console.log('build-ignore-files unload');
}
This is my code.
Also, for those who proceed with the construct, the file might 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 you could refresh/replace belongings db, most likely is healthier 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 take advantage of the assetdb?
[ad_2]