我以为有办法做到这一点,我以前偶然发现了它.我已经阅读了这些答案,但它们并不是我所说的:
我也查看了咕噜咕噜的文档,但它不存在:
https://github.com/gruntjs/grunt/wiki/Configuring-tasks
有这样的语法吗?
grunt.task.run 'htmlmin:allFiles:collapseWhitespace=true'
dc5*_*dc5 55
您可以使用该语法,但这意味着将这些参数传递给htmlmin任务:allFiles,'collapse=true'.
例如,给定以下任务:
grunt.registerTask('so', function(arg1, arg2) {
console.log(arg1 + ", " + arg2);
});
Run Code Online (Sandbox Code Playgroud)
运行:
grunt so:barley:test=true
Run Code Online (Sandbox Code Playgroud)
给出以下输出:
barley, test=true
Run Code Online (Sandbox Code Playgroud)
还有其他方法可以传递faq中描述的参数/共享信息:如何跨多个任务共享参数?
- 选项可能适用于您
另一种跨多个任务共享参数的方法是使用
grunt.option.在此示例中,grunt deploy --target=staging在命令行上运行将导致grunt.option('target')返回"staging".
| 归档时间: |
|
| 查看次数: |
28807 次 |
| 最近记录: |