Configuring tasks
Grunt configuration can be thought of as single JavaScript object, though, instead of assigning values, we'll use functions provided by Grunt to get and set properties.
We briefly touched on Grunt configuration in Chapter 1, Introducing Grunt, displaying simple uses of the grunt.initConfig
, grunt.config.get
and grunt.config.set
functions. The grunt.initConfig
function (which as mentioned earlier, is aliased from grunt.config.init
) accepts an object, which is then used as the starting point for our configuration, whereas the grunt.config.get
and grunt.config.set
functions are used to get and set individual properties. We can also use the shorter grunt.config
function, which works like jQuery getters and setters. When called with one argument it aliases to grunt.config.get
, and with two arguments, it aliases to grunt.config.set
. Each line in the following example is functionally equivalent:
grunt.config.init({ foo: { bar: 7 }}); grunt.config.set('foo.bar', 7); grunt.config...