一个 g运行t 任务可以 运行 其他 g运行t 任务吗?

Can a grunt task run other grunt tasks?

所以我的意思是:

grunt.registerTask('default', ['default']); // CLI: grunt
grunt.registerTask('serve', ['serve']); // CLI: grunt serve
grunt.registerTask('test', ['test']); // CLI: grunt test

然后我只想要一个任务,它在一个调用中运行其中的 3 个任务,例如,如果我输入 cmd "grunt tasks",它会运行我想要的任何任务,例如默认、服务或测试我指定的顺序等

这能做到吗?文档不是很清楚(也许是我的运动障碍,但它对我来说读起来不太好)。

干杯,

-- 标准差

是的,你可以很容易。

来自文档:

You can configure Grunt to run one or more tasks by default by defining a default task. In the following example, running grunt at the command line without specifying a task will run the uglify task. This is functionally the same as explicitly running grunt uglify or even grunt default. Any number of tasks (with or without arguments) may be specified in the array.

以上摘录的关键部分已加粗。

例如,创建一个名为 runAllThree 的任务,然后在数组中指定您想要 运行 的所有三个任务。

grunt.registerTask('runAllThree', ['default', 'serve', 'test']);