Dojo 1.7 custom build - How to remove unused files from the release folder

2.6k views Asked by At

I have used the below (1.7) custom build profile to build my release folder.

var profile = {
basePath: "..",
action: "release",
cssOptimize: "comments",
mini: true,
optimize: "closure",
layerOptimize: "closure",
stripConsole: "all",
selectorEngine: "acme",
packages:[
    {
        name: "dojo",
        location: "./../../dojo"
    },

    {
        name: "dijit",
        location: "./../../dijit"
    },

    {
        name: "dojox",
        location: "./../../dojox"
    }
],

layers: {
    "dojo/dojo": {
        include: [
                            "dojo/dojo",
                            "dijit/form/Button",
                            "dojox/form/TimeSpinner"
                    ],
        customBase: true,
        boot: true
    }
},

resourceTags: {
    amd: function (filename, mid) {
        return /\.js$/.test(filename);
    }
} };

In my web application, I am using just two components, one is Button from 'dijit' package and another one is TimeSpinner from 'dojox'. So, I have included these two components in to 'dojo/dojo.js' file, it is working as I have expected.

But the release folder contains the folders 'dojo', 'dijit' and 'dojox' with lot of files.

Most of the components are not used in my web application, but their files are present in the release folder. Even though they will not be loaded in to the browser (because of AMD), I don't want to have such files in my release folder.

It is unnecessary to maintain such huge number of files in my subversion.

So, my questions are below:

  1. How to remove '.uncompressed.js' files from the release folder?
  2. How to remove the files, CSS, templates of unused components from the release folder ?

Please help me...

2

There are 2 answers

0
mschr On

The dojo build utility is not meant to separate a subset of files and does not have configuration for this.

The builder makes compression, it wraps legacy modules into amd styled declarations and it combines layers in a cached module loading fashion.

This means that once you create the dojo/dojo, customBase (this is highly advanced setting btw, careful with usage) layer - a dependency tree is built. The dependency tree is a list of files which each are compressed and sutured together similar to following;

// file: dojo/dojo.js
declare(
  {cache: 
     {
      "moduleDep_1": dojo.cache("moduleDep_1", {}),
      "moduleDep_2": dojo.cache("modu...", .. )
     }, "dojo/dojo", null, {

  dojo/dojo here

});

What if your visitor has a base-dependency which youve left out?

Anyways, the older build utility had a functionality dependencyList which is not present at the 1.7 build utility. This would have 'saved' you :)

If youre 100% certain that the only file which is needed is your layerfile - why not simply upload that single file to your webhotel?

3
Manu On

You can add the following lines at the bottom of build.sh

find . -type f -name '*.uncompressed.js' -print0 | xargs -0 rm -rdf

find . -type f -name '*.consoleStripped.js' -print0 | xargs -0 rm -rdf