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 |
|
35 | ## Options
|
36 |
|
37 | ### limit
|
38 |
|
39 | Type: `number`
|
40 | Default: Twice the number of CPU cores with a minimum of 2
|
41 |
|
42 | Limit how many tasks that are run concurrently.
|
43 |
|
44 | ### logConcurrentOutput
|
45 |
|
46 | Type: `boolean`
|
47 | Default: `false`
|
48 |
|
49 | 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:
|
50 |
|
51 | ```js
|
52 | grunt.initConfig({
|
53 | concurrent: {
|
54 | target: {
|
55 | tasks: ['nodemon', 'watch'],
|
56 | options: {
|
57 | logConcurrentOutput: true
|
58 | }
|
59 | }
|
60 | }
|
61 | });
|
62 |
|
63 | grunt.loadNpmTasks('grunt-concurrent');
|
64 | grunt.registerTask('default', ['concurrent:target']);
|
65 | ```
|
66 |
|
67 | *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.*
|
68 |
|
69 |
|
70 | ## License
|
71 |
|
72 | MIT © [Sindre Sorhus](http://sindresorhus.com)
|