Home Game Development To exclude js recordsdata from a construct – Cocos Creator

To exclude js recordsdata from a construct – Cocos Creator

0
To exclude js recordsdata from a construct – Cocos Creator

[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 resulting from private causes.

My drawback is, this js file doesn’t should be included within the construct, but it surely 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 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 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 possibly can modify a construct course of by way of an editor extension that you want to 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, when you 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 want to refresh/replace belongings db, in all probability is healthier delete file by way of assets-db API instantly as a substitute of FileSystem API.

[ad_2]

LEAVE A REPLY

Please enter your comment!
Please enter your name here