I am working on adding Grunt build system for an Angular/Cordova project. I am struggling to understand the behavior of inheritance / overriding of options for tasks.
I am working on configuring plugins grunt-contrib-jade and grunt-preprocessor but I am not not sure if I understand the business of overriding options correctly.
This is my whole Gruntfile.js for reference to ensure that I am not missing something.
'use strict';
module.exports = function(grunt) {
require('load-grunt-tasks')(grunt);
require("time-grunt")(grunt);
grunt.initConfig({
connect: {
serve: {
options: {
base: 'www/',
keepalive: true,
open: true
}
}
},
copy: {
all: {
expand: true,
src: '**',
dest: '../www/',
cwd: 'app'
//filter: 'isFile'
}
},
compass: {
options: {
sassDir: 'app/style',
cssDir: 'www/style',
},
dev: {
debugInfo: true
}
},
preprocess: {
dev: {
options: {
context: {
MODE: 'prod'
}
},
src: 'app/index.html',
dest: 'www/index.html'
}
},
jade: {
dev: {
options: {
src: 'app/**/*.jade',
dest: 'www/',
expand: true,
ext: '.html',
pretty: true
}
}
},
shell: {
runAndroid: {
command: 'cordova run android'
},
buildAndroid: {
command: 'cordova build android'
}
}
});
grunt.registerTask('default', ['connect:serve']);
grunt.registerTask('run-android', ['shell:runAndroid']);
grunt.registerTask('build-android', ['shell:buildAndroid']);
};
Here are a few example of the plugin configurations and their behavior,
When run with grunt -vv jade following configuration prints no files[] and options[] and no output files are generated.
jade: {
options: {
src: 'app/**/*.jade',
dest: 'www/',
expand: true,
ext: '.html',
pretty: true
}
}
When run grunt -vv jade:dev with following configuration, things work perfectly and output files are generated along with files[] and options[] array being printed on the console with appropriate values.
jade: {
dev: {
src: 'app/**/*.jade',
dest: 'www/',
expand: true,
ext: '.html',
pretty: true
}
}
When run with gunt -vv jade:dev with following configuration, output files are not generated and files[] is empty but options[] is printed correctly on console.
jade: {
dev: {
options: {
src: 'app/**/*.jade',
dest: 'www/',
expand: true,
ext: '.html',
pretty: true
}
}
}
I am trying to do something like following where I will have default options set at the task level but can override / add a few options for a specific target.
jade: {
options: {
src: 'app/**/*.jade',
dest: 'www/',
expand: true,
ext: '.html',
},
dev: {
options: {
pretty: true
}
}
}
Am I missing something?
Versions used,
0.4.50.1.30.12.04.0.0