Module: grunt/ngDpTask

(static) (require("grunt/ngDpTask"))(grunt) → {function}

Defines a grunt task to build the list of sources (css and js) of an AngularJS application.

Parameters:
Name Type Description
grunt Object

Grunt instance

Source:
Returns:

Task function

Type
function
Example
// Register task
var openVeoApi = require('@openveo/api');
grunt.registerMultiTask('ngDp', openVeoApi.grunt.ngDpTask(grunt));

// Configure task
grunt.initConfig({
  'ngDp': {
    options: {
      basePath: '/path/to/the/',
      cssPrefix: '../../other/css/path/',
      jsPrefix: '../../other/js/path/'
    },
    app1: {
      src: '/path/to/the/app1/**\/*.*',
      dest: '/path/to/the/app1/topology.json'
    },
    app2: {
      src: '/path/to/the/app2**\/*.*',
      dest: '/path/to/the/app2/topology.json'
    }
  }
});

// Ouput example (/path/to/the/app1/topology.json)
{
  js: ['../..other/js/path/app1/file1.js', '../..other/js/path/app1/file2.js', [...]],
  css: ['../..other/css/path/app1/file1.css', '../..other/css/path/app1/file2.css', [...]]
}

AngularJS applications, which respect components architecture, need to be loaded in the right order as some
components may depend on other components. This task helps build an array of JavaScript files and css / scss files
in the right order.

For this to work, each module must be declared in a separated file and a single file should not define AngularJS
elements belonging to several different modules.

Available options are:
  - basePath: The base path which will be replaced by the cssPrefix or jsPrefix
  - cssPrefix: For CSS / SCSS files, replace the basePath by this prefix
  - jsPrefix: For JS files, replace the basePath by this prefix