Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to build a Dojo module that includes a single file from the package location?

I have the following build profile for a small app:

var profile = (function(){

    var copyOnly = function(filename, mid){
        /* ..snip.. */
    };

    return {
        basePath: "../../src",
        releaseDir: "../dist",
        releaseName: "lib",
        action: "release",

        packages: [
        'dojo',
        'dijit',
        //'dojox',
        'amd',
        {
            name: 'lodash',
            location: 'lodash',
            trees: [
                [".", ".", /(\/\.)|(~$)|(vendor|test)/]
            ]
        },
        {
            name: 'd3',
            location: 'd3',
            main: 'd3.min',
            trees: [
                [".", ".", /(\/\.)|(~$)|(src|lib|test)/]
            ]
        },
        { name: 'app', location: 'app' }
    ],

        layers: {
            "dojo/dojo": {
                include: [ "dojo/dojo", "amd/d3","amd/gmaps",
                    "app/main", "app/run" ],
                customBase: true,
                boot: true
            }
        },

        resourceTags: {
            /* ..snip.. */
        }
    };
})();

The problem is this: all I need is the lodash.min.js file to be processed by the Dojo build system. Unfortunately, when you include a package definition in your profile, the build system looks at all files in the relevant directory using an implicit trees value. You can overwrite it (as I have done here) and add some ignore directives, but this is ugly and leaves you open to missing something of. What I'd like to do is affirmatively indicate precisely which file(s) that I'm interested in processing for my build process.

Does Dojo allow you to do this? The documentation is a little scant in this area, but if you can help me find a resource that explains this more clearly, that would be great!

like image 309
Dancrumb Avatar asked Jan 20 '13 01:01

Dancrumb


1 Answers

As of 1.9 at least, I believe this can be done:

// ... snip ...
{
    name:'lodash',
    location:'lodash',
    trees:[],
    dirs:[],
    files:[
        ["lodash.min.js"]
    ]
},

This explicitly lists the files, while also squashing implicit tree and directory discovery.

My belief here is based on a cursory review of util/build/discover.js -- but as I read the documentation files only should be supported.

like image 72
bishop Avatar answered Nov 19 '22 21:11

bishop