UNPKG

2.27 kBMarkdownView Raw
1# grunt-concurrent [![Build Status](https://travis-ci.org/sindresorhus/grunt-concurrent.svg?branch=master)](https://travis-ci.org/sindresorhus/grunt-concurrent)
2
3> Run grunt tasks concurrently
4
5<img src="screenshot.png" width="439">
6
7Running 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](#logconcurrentoutput) like `nodemon` and `watch` at once.
8
9
10## Install
11
12```
13$ npm install --save-dev grunt-concurrent
14```
15
16
17## Usage
18
19```js
20require('load-grunt-tasks')(grunt); // npm install --save-dev load-grunt-tasks
21
22grunt.initConfig({
23 concurrent: {
24 target1: ['coffee', 'sass'],
25 target2: ['jshint', 'mocha']
26 }
27});
28
29// tasks of target1 run concurrently, after they all finished, tasks of target2 run concurrently,
30// instead of target1 and target2 run concurrently.
31grunt.registerTask('default', ['concurrent:target1', 'concurrent:target2']);
32```
33
34## Sequential tasks in concurrent target
35
36```js
37grunt.initConfig({
38 concurrent: {
39 target: [['jshint', 'coffee'], 'sass']
40 }
41});
42```
43Now `jshint` will always be done before `coffee` and `sass` runs independent of both of them.
44
45
46## Options
47
48### limit
49
50Type: `number`
51Default: Twice the number of CPU cores with a minimum of 2
52
53Limit how many tasks that are run concurrently.
54
55### logConcurrentOutput
56
57Type: `boolean`
58Default: `false`
59
60You can optionally log the output of your concurrent tasks by specifying the `logConcurrentOutput` option. Here is an example config which runs [grunt-nodemon](https://github.com/ChrisWren/grunt-nodemon) to launch and monitor a node server and [grunt-contrib-watch](https://github.com/gruntjs/grunt-contrib-watch) to watch for asset changes all in one terminal tab:
61
62```js
63grunt.initConfig({
64 concurrent: {
65 target: {
66 tasks: ['nodemon', 'watch'],
67 options: {
68 logConcurrentOutput: true
69 }
70 }
71 }
72});
73
74grunt.loadNpmTasks('grunt-concurrent');
75grunt.registerTask('default', ['concurrent:target']);
76```
77
78*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.*
79
80
81## License
82
83MIT © [Sindre Sorhus](http://sindresorhus.com)