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 |
|
7 | 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](#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
|
20 | require('load-grunt-tasks')(grunt); // npm install --save-dev load-grunt-tasks
|
21 |
|
22 | grunt.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.
|
31 | grunt.registerTask('default', ['concurrent:target1', 'concurrent:target2']);
|
32 | ```
|
33 |
|
34 | ## Sequential tasks in concurrent target
|
35 |
|
36 | ```js
|
37 | grunt.initConfig({
|
38 | concurrent: {
|
39 | target: [['jshint', 'coffee'], 'sass']
|
40 | }
|
41 | });
|
42 | ```
|
43 | Now `jshint` will always be done before `coffee` and `sass` runs independent of both of them.
|
44 |
|
45 |
|
46 | ## Options
|
47 |
|
48 | ### limit
|
49 |
|
50 | Type: `number`<br>
|
51 | Default: Twice the number of CPU cores with a minimum of 2
|
52 |
|
53 | Limit how many tasks that are run concurrently.
|
54 |
|
55 | ### logConcurrentOutput
|
56 |
|
57 | Type: `boolean`<br>
|
58 | Default: `false`
|
59 |
|
60 | You 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
|
63 | grunt.initConfig({
|
64 | concurrent: {
|
65 | target: {
|
66 | tasks: ['nodemon', 'watch'],
|
67 | options: {
|
68 | logConcurrentOutput: true
|
69 | }
|
70 | }
|
71 | }
|
72 | });
|
73 |
|
74 | grunt.loadNpmTasks('grunt-concurrent');
|
75 | grunt.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 |
|
83 | MIT © [Sindre Sorhus](http://sindresorhus.com)
|