gpt4 book ai didi

gruntjs - 如何同时运行两个 grunt watch 任务

转载 作者:行者123 更新时间:2023-12-03 05:45:35 25 4
gpt4 key购买 nike

是否可以同时运行两个监视任务?

我知道我可以在watch设置中执行任意数量的任务,只需启动grunt watch,它就会监视所有任务,就像这样

...
watch: {
A: {
files: "js/dev/**/*.coffee",
tasks: ["coffee", "requirejs"]
},
B: {
files: "js/dev/**/*.coffee",
tasks: ["coffee"]
},
C: {
files: "js/dev/**/*.html",
tasks: ["copy"]
}
}
...

...但我不需要这个。我只是想为开发和生产执行不同的任务。正如您所猜测的,A(生产)和B(开发)之间的唯一区别是缩小和串联。我不需要同时启动 AB 任务。

首先我有这个想法

grunt.registerTask("prod", ["watch:A", "watch:C"]);
grunt.registerTask("dev", ["watch:B", "watch:C"]);

但这没有用。只是第一个监视任务正在工作(C 永远不会工作)。可以做我想做的事吗?

最佳答案

我发现使用 grunt-concurrent作品:

concurrent: {
options: {
logConcurrentOutput: true
},
prod: {
tasks: ["watch:A", "watch:C"]
},
dev: {
tasks: ["watch:B", "watch:C"]
}
}

然后:

grunt.registerTask("prod", ["concurrent:prod"]);
grunt.registerTask("dev", ["concurrent:dev"]);

关于gruntjs - 如何同时运行两个 grunt watch 任务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17585385/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com