Closed tfrommen closed 8 years ago
I just improved the new delegate
task.
As we need at least src
specified for the task/target, the delegate
task is now a multi task, requiring a config.
I also integrated the possibility to specify a custom task (with an optional target).
Her's the above example, a little bit expanded:
grunt.initConfig( {
delegate: {
sass: {
src: [ 'resources/scss/**/*.scss' ]
},
sass_foo: {
task: 'sass:foo',
src: [ 'resources/scss/foo/*.scss' ]
},
'sass-styles': {
task: 'sass:styles',
src: [ 'resources/scss/**/*.scss' ]
}
},
sass: {
foo: {
expand: true,
cwd: 'resources/scss/',
src: [ 'foo.scss' ],
dest: 'assets/css/',
ext: '.css'
},
styles: {
expand: true,
cwd: 'resources/scss/',
src: [ '*.scss' ],
dest: 'assets/css/',
ext: '.css'
}
}
} );
When calling $ grunt newer:delegate:sass
, the sass
task will be executed (with all available targets). Calling $ grunt newer:delegate:sass-foo
only runs sass:foo
, while $ grunt newer:delegate:sass-styles
results in running sass:styles
.
All runs are only performed if there are changed files wrt. the src
given in the according delegate
target.
Of course, you can still call a task with a target directly via command line, for instance $ grunt newer:delegate:sass:styles
.
I just published this (in a more condensed form) as new Grunt plugin: grunt-delegate
.
As stated in https://github.com/tschaub/grunt-newer/issues/29#issuecomment-160223515, I added a simple delegation task (named
delegate
). This allows to specifiy for individual taskssrc
(and alsodest
) for newer to check, and then actually run the task with its ownsrc
( anddest
). This is useful for SASS/LESS.With the following config:
one could simply run
grunt newer:delegate:sass:styles
to actually havesass:styles
be run when there are new.scss
files (even in subfolders).