Run grunt tasks concurrently by depends
Running slow tasks like Coffee and Sass concurrently can potentially improve your build time significantly. This task is also useful if you need to run multiple blocking tasks like nodemon
and watch
at once.
$ npm install --save-dev grunt-concurrentdep
require('jit-grunt')(grunt); // npm install --save-dev jit-grunt
grunt.initConfig({
concurrentdep: {
app: {
concat: ['csslint','jshint'],
cssmin: ['concat'],
csslint: ['preprocess'],
jshint: ['preprocess'],
uglify: ['concat'],
phplint: []
}
}
});
grunt.registerTask( "default",['concurrentdep']);
┌ csslint ┐ ┌ uglify ┐
run: ┌ preprocess ┤ ├ concat ┤ ├┐
start ┤ └ jshint ─┘ └ cssmin ┘├ done
└ phplint ────────────────────────────────┘
Type: number
Default: 4
Limit how many tasks that are run concurrently.
Type: boolean
Default: true
You can optionally show taskduration
Type: boolean
Default: false
You can optionally log the output of your concurrent tasks by specifying the logConcurrentOutput
option. Here is an example config which runs grunt-nodemon to launch and monitor a node server and grunt-contrib-watch to watch for asset changes all in one terminal tab:
grunt.initConfig({
concurrentdep: {
options: {
logConcurrentOutput: true
},
app: {
...
}
}
});
grunt.loadNpmTasks('grunt-concurrentdep');
grunt.registerTask('default', ['concurrentdep:app']);
The output will be messy when combining certain tasks. This option is best used with tasks that don't exit like watch
and nodemon
to monitor the output of long-running concurrent tasks.
Based on grunt-concurrent