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 based mostly on nodejs for comfort of growth. It can be within the asset folder and can’t be rerouted attributable to private causes.

My downside 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 strategy to exclude the javascript file within the asset folder from the construct?

Hi, you may 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 is advisable 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 checklist = (module['ignoreList'] || '').break up(';');
    for (let i = checklist.size - 1; i >= 0; i--) {
        checklist.push(checklist[i] + '.meta');
    }
    for (let path of checklist) {
        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 checklist = (module['ignoreList'] || '').break up(';');
    for (let i = checklist.size - 1; i >= 0; i--) {
        checklist.push(checklist[i] + '.meta');
    }
    for (let path of checklist) {
        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 will likely 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?

[ad_2]

LEAVE A REPLY

Please enter your comment!
Please enter your name here