[grunt] grunt-concurrent 介绍
发布于 4 年前 作者 qjzd 2270 次浏览 来自 码农

git地址

https://github.com/sindresorhus/grunt-concurrent

介绍

Run grunt tasks concurrently

并行Grunt任务

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.

并发运行缓慢的任务就像Coffee和Sass, 可能显著改善您的构建时间。如果要一次运行nodmon和watch,grunt-concurrent这个插件是很有用的。

Install

$ npm install --save-dev grunt-concurrent

Usage

require('load-grunt-tasks')(grunt); // npm install --save-dev load-grunt-tasks

grunt.initConfig({
	concurrent: {
		target1: ['coffee', 'sass'],
		target2: ['jshint', 'mocha']
	}
});
// tasks of target1 run concurrently, after they all finished, tasks of target2 run concurrently,
// instead of target1 and target2 run concurrently.
grunt.registerTask('default', ['concurrent:target1', 'concurrent:target2']);
/ /任务target1同时运行,他们都完成后,任务target2同时运行,
/ /而不是target1 target2并发运行。
grunt.registerTask('default', ['concurrent:target1', 'concurrent:target2']);

Options 选项

limit

Type: number
Default: Twice the number of CPU cores with a minimum of 2 Limit how many tasks that are run concurrently.

Type: `number`  
Default: CPU核数量的两倍,最低为2
限制有多少并发运行的任务。

logConcurrentOutput 并发输出日志

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:

你通过指定“logConcurrentOutput”选项可以选择日志的输出并发任务, 这里有一个例子配置 , 这个例子启动和监控 node server 和 在一个终端选项卡关注所有资源变化。
grunt.initConfig({
	concurrent: {
		target: {
			tasks: ['nodemon', 'watch'],
			options: {
				logConcurrentOutput: true
			}
		}
	}
});

grunt.loadNpmTasks('grunt-concurrent');
grunt.registerTask('default', ['concurrent:target']);

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.

*当结合某些任务,输出将会时混乱的。这个选项是最好和哪些不像
如果任务,不会退出,会在后台一起运行, 这个选项logConcurrentOutput最好不要用。
最像像watch和nodemon任务,这两个任务监控长时间运行的并发任务的输出。
回到顶部