任务alias
If a task list is specified, the new task will be an alias for one or more other tasks. Whenever this "alias task" is run, every specified tasks intaskList
will
be run, in the order specified. ThetaskList
argument
must be an array of tasks.
grunt.registerTask(taskName, [description, ] taskList)
This example alias task defines a "default" task whereby the "jshint", "qunit", "concat" and "uglify" tasks are run automatically if Grunt is executed without specifying any tasks:
grunt.registerTask('default', ['jshint', 'qunit', 'concat', 'uglify']);
Task arguments can be specified as well. In this example, the alias "dist" runs both the "concat" and "min" tasks, each with a "dist" argument:
grunt.registerTask('dist', ['concat:dist', 'uglify:dist']);
多个Target的Task
When a multi task is run, Grunt looks for a property of the same name in the Grunt configuration. Multi-tasks can have multiple configurations, defined using arbitrarily named "targets."
Specifying both a task and target likegrunt
concat:foo
orgrunt concat:bar
will
process just the specified target's configuration, while runninggrunt
concat
will iterate overalltargets, processing each in turn. Note that if a task has been renamed withgrunt.renameTask,
Grunt will look for a property with thenewtask name in the config object.
Most of the contrib tasks, including thegrunt-contrib-jshint plugin jshint task,concat
taskandgrunt-contrib-concat plugin concat taskare multi tasks.
grunt.registerMultiTask(taskName, [description, ] taskFunction)
Given the specified configuration, this example multi task would logfoo:
1,2,3
if Grunt was run viagrunt log:foo
,
or it would logbar: hello world
if
Grunt was run viagrunt log:bar
. If
Grunt was run asgrunt log
however,
it would logfoo: 1,2,3
thenbar:
hello world
thenbaz: false
.
grunt.initConfig({
log: {
foo: [1, 2, 3],
bar: 'hello world',
baz: false
}
});
grunt.registerMultiTask('log', 'Log stuff.', function() {
grunt.log.writeln(this.target + ': ' + this.data);
});
有多个Target的任务称为Multi Task,可以用grunt task:target的命令来指定启动哪个target,如果就用grunt task的话,将顺序执行所有的target。target存在的目的,主要是为了应用不同的配置项。注意,target并不是maven中goal的概念
分享到:
相关推荐
$ npm install --save get-grunt-tasks 用法 想象一下gruntfile.js中的./grunt-project : module . exports = grunt => { grunt . registerTask ( 'default' ) ; grunt . registerTask ( 'test' ) ; } ; 您...
前端开源库-rx-grunt-tasksRx Grunt任务,开始使用公司Grunt任务:
该模块将读取package.json中的dependencies / devDependencies / peerDependencies / optionalDependencies并加载与提供的模式匹配的grunt任务。 前 grunt . loadNpmTasks ( 'grunt-shell' ) ; grunt . ...
'grunt-tasks' 模块允许将您的 Gruntfile 分解为多个以您喜欢的方式组织的模块。 它通过加载含有咕噜任务定义文件模式(#2)。 变量 (#1) 和别名 (#4) 可以设置为对象文字,也可以指定为包含这些设置的 .js 文件的...
Construct your own Grunt tasks, multi-tasks, and asynchronous tasks Approach A step-by-step, practical tutorial to help you transform into a Grunt power-user. Who this book is written for This book...
grunt-drupal-tasks, 面向Drupal的Grunt构建和测试任务 Grunt Drupal任务用于自动化 Drupal 7和 Drupal 8构建和测试任务的Grunt插件。代码状态( 主分支): 特性这个项目构建在Grunt社区的工具之上,提供了许多 PHP &...
前端开源库-grunt-available-tasks咕噜可用任务,列出可用咕噜任务和目标。
本自述文件适用于grunt-babel v8 + Babel v7使用...require ( 'load-grunt-tasks' ) ( grunt ) ; // npm install --save-dev load-grunt-tasks grunt . initConfig ( { babel : { options : { sourceMap : true ,
该模块为grunt.registerTask提供了一个包装函数, grunt.registerTask tasks对象作为其第二个参数,您可以在其中指定需要注册的所有任务。前 grunt . registerTask ( 'backup' , 'compress:src' ) ,grunt . ...
require ( 'load-grunt-tasks' ) ( grunt ) ; // npm install --save-dev load-grunt-tasks grunt . initConfig ( { removeHtmlComments : { target : { src : 'src/index.html' , dest : 'dest/index.html' }...
require ( 'load-grunt-tasks' ) ( grunt ) ; // npm install --save-dev load-grunt-tasks grunt . initConfig ( { styl : { dist : { options : { use : [ require ( 'rework-npm' ) ( ) ] } , ...
咕噜噜包含: 出版商jsdoc 主题报道主题github页面自动化执照版权所有 2014 Robin Radic
Grunt, along with its wide range of plugins, provides a simple way of managing the large number of build tasks required to maintain a sophisticated web application. Getting Started with Grunt: The ...
grunt运行的命令行 放在C:\Users\Administrator\AppData\Roaming\npm\node_modules\grunt-cli下的
碎片化的任务 提供碎片化在多个文件中的 grunt 任务模式
require ( 'load-grunt-tasks' ) ( grunt ) ; // npm install --save-dev load-grunt-tasks grunt . initConfig ( { minifyHtml : { options : { cdata : true } , dist : { files : { 'dist/...
require ( 'load-grunt-tasks' ) ( grunt ) ; // npm install --save-dev load-grunt-tasks grunt . initConfig ( { stripCssComments : { dist : { files : { 'dist/app.css' : 'src/app.css' } } ...
require ( 'load-grunt-tasks' ) ( grunt ) ; // npm install --save-dev load-grunt-tasks grunt . initConfig ( { uncommentIt : { target : { src : 'src/index.html' , dest : 'dest/index.html' } } } )...
require ( 'load-grunt-tasks' ) ( grunt ) ; grunt . initConfig ( { concurrent : { target1 : [ 'coffee' , 'sass' ] , target2 : [ 'jshint' , 'mocha' ] } } ) ; // Tasks of target1 run concurrently, ...
小工具将使用站点框架和工具设置一个Drupal项目,以构建您的项目并使用Grunt Drupal Tasks套件配置您的构建系统。 自动使用最新版本的Grunt Drupal Tasks。 从Drupal 7,Drupal 8,Atrium 2或Octane中选择。 将...