How to exclude files from Dojo's Build System?

Refresh

December 2018

Views

1.8k time

2

I'm following the official documentation page about the topic but I cannot configure it to ignore .txt files.

I have a all.profile.js on the root of my project:

var profile = (function(){
    return {
        basePath: "./",
        releaseDir: "../web",
        action: "release",
        layerOptimize: "closure",
        optimize: "closure",
        cssOptimize: "comments",
        mini: true,
        stripConsole: "all",

        packages: [
            { name: "myapp", location: "myapp" }
        ]
    };
})();

And this is the package.json inside the folder myapp:

{
    "dojoBuild": "myapp.profile.js",
    "name": "my-app",
    "description": "This is My App",
    "version": "1.0",
    "main": "src"
}

And this is the myapp.profile.js also inside the folder myapp:

var profile = (function(){
    return {
        // don't need to do anything on the 'test' folder so don't define it on the trees.
        trees: [
            ["libs","libs",/txt$/], // ignore .txt files -> DOESN'T WORK!
            ["src","src",/txt$/]    // ignore .txt files -> DOESN'T WORK!
        ],
        resourceTags: {
            test: function(filename, mid){
                console.log("[test] filename: ",filename);
                return filename.indexOf("test/") !== -1;
            },
            copyOnly: function(filename, mid){
                //console.log("[copyOnly] mid: ",mid);
                return false;
            },
            miniExclude: function (filename, mid) {
                console.log("[miniExclude] filename: ",filename);
                return mid in {
                    'myapp/myapp.profile': 1,
                    'myapp/package.json': 2
                } || mid.indexOf(".txt") !== -1; // .txt are not ignored so exclude them...
            },
            amd: function(filename, mid) {
                //console.log("[amd] mid: ",mid);
                // myapp is not AMD but this will 'convert' it
                return false;
            }
        }
    };
})();

Finally, this is the folder structure:

web_dev/
-- myapp/
---- libs/
---- src/
---- test/
---- myapp.profile.js
---- package.json
-- all.profile.js

The build tool runs fine, it reads and process all files but the .txt files are still on the release dir.

Please let me know if you spot any mistakes on my logic or how I'm configuring the build system. I'm using Dojo 1.9.1.

Thanks in advance.

1 answers

1

Я не уверен, что случилось с моим начальным сценарием, но вот те изменения, которые я сделал, чтобы иметь желаемый результат:

  1. Переместить treesдекларацию от myapp.profile.jsTo all.profile.jsвнутри «MYAPP» определения пакета.
  2. Вместо того, чтобы указать корень деревьев, проверить все и исключить соответственно: [".", ".", /(\/\.)|(~$)|(test|txt)/]

Окончательный all.profile.js:

var profile = {
    basePath: "./",
    releaseDir: "../web",
    releaseName: "built",
    action: "release",
    layerOptimize: "closure",
    optimize: "closure",
    cssOptimize: "comments",
    mini: true,
    stripConsole: "all",

    packages: [
        {
            name: "myapp",
            location: "myapp",
            trees: [
                // don't bother with .hidden, tests and txt.
                [".", ".", /(\/\.)|(~$)|(test|txt)/]
            ]
        }
    ]
};

Если кто-то может точно указать точно, что я делаю неправильно, пожалуйста, поделитесь.