Skip to content
Clément Mathieu edited this page Jan 9, 2014 · 5 revisions

#Developer API description

amdBuild

This task is the main entry point for the build plugin. It does the following:

  1. Normalize the config. The config property in the Gruntfile is either amdBuild or the task first argument (ie, configProp if the task amdBuild:configProp is run)

  2. Select the tasks to run according to the config provided in the Gruntfile (minification, inlining of plugin resources...)

  3. Create a grunt config object to store internal data and normalized config. It will be named configProp_api.

  4. Apply the tasks list for each layer. The tasks will be run as task:configProp:layerName

configProp_api at the end of the task:

{
    normalized copy of grunt config,
    pkgs,   //normalized packages with main and location
    layers, //normalized layers with include, exclude, output path
            //    and include contains the layer name.  
}

depsScan

This task lists all the modules and plugins dependencies of a layer. This task MUST be run first, before any other tasks.

  1. List the modules to exclude (the ones in the configProp_api.layers.layerName.exclude array and their dependencies)

  2. List all the modules and plugins to include, and store them in configProp_api

configProp_api at the end of the task:

{   
    ...
    layers: {
        layerName: {
            modules: {
                mid: {
                    mid: "",
                    content: “”,
                    deps: [],
                    includeDeps: [],
                    filepath: “”
                }
            },
            plugins: {
                mid: [“resource”, “...”],
                ...
            },
            include: [...],
            exclude: [...],
            outputPath: “...”
        },
        ...    
    },  
}

buildPlugin

This task relies on the AMD plugin api by RequireJS (http://requirejs.org/docs/plugins.html). It is used to inline plugin resources at build time. The inlined resources are then added to the modules object.

amdConcat

This task writes all the module from the modules object to the outputPath layer.

amdUglify

This task writes the uglify configuration and call the uglify grunt task.

Clone this wiki locally