Gruntfile

General rules

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

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);
    });