Gruntfile

General rules

  • Use _dev and _package to add new tasks
  • _dev is executed on grunt serve
  • _package is executed on grunt package

Explanation

grunt package command is used by Dana build platform to generate release ready application.

Examples

Index management

Do not add task based on fixed index, find the index of the task just before.

WRONG :

    grunt.registerTask("_dev", function () {
        // Get tasks
        let tasks = this.options().tasks;

        tasks.splice(12, 0, 'copy:lightningjs');

        // Run tasks
        grunt.task.run(tasks);
    });

GOOD :

    grunt.registerTask("_dev", function () {
        // Get tasks
        let tasks = this.options().tasks;

        tasks.splice(tasks.indexOf('bundle'), 0, 'copy:lightningjs');

        // Run tasks
        grunt.task.run(tasks);
    });

Profile name

Do not add task based on profile naming but based on profile flags.

WRONG :

    grunt.registerTask("_dev", function () {
        // Get tasks
        var tasks = this.options().tasks;
        let profile = grunt.file.readJSON(grunt.config("resolveConfig.options.resolvedConfigFilePath"));

        if (profile.includes("lightning") {
            tasks.splice(tasks.indexOf('bundle'), 0, 'copy:lightningjs');
        }

        // Run tasks
        grunt.task.run(tasks);
    });

GOOD :

    grunt.registerTask("_dev", function () {
        // Get tasks
        var tasks = this.options().tasks;
        let profile = grunt.file.readJSON(grunt.config("resolveConfig.options.resolvedConfigFilePath"));

        if (profile.isLightning) {
            tasks.splice(tasks.indexOf('bundle'), 0, 'copy:lightningjs');
        }

        // Run tasks
        grunt.task.run(tasks);
    });