Question

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.

Was it helpful?

Solution

I'm not sure what is wrong with my initial scenario but here are the changes that I made to have the desired result:

  1. Move the trees declaration from the myapp.profile.js to all.profile.js inside the 'myapp' package definition.
  2. Instead of specifying the root of the trees, check everything and exclude accordingly: [".", ".", /(\/\.)|(~$)|(test|txt)/]

The final 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)/]
            ]
        }
    ]
};

If anyone can pin point exactly what I was doing wrong, please share.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top