Is it possible to run two watch tasks simultaneously?
I understand that I can have any number of tasks I want inside watch settings and just launch grun
grunt-concurrent or grunt-focus are both good solutions, but both of them break livereload
functionality.
My solution to this is to compose the watch configuration dynamically, with the assumption that you won't be running both configuration at the same time.
You can do something like this
grunt.config.merge({
watch: {
options: {
livereload: true
},
C: {
files: "js/dev/**/*.html",
tasks: ["copy"]
}
}
});
grunt.registerTask('watch-forProd', function () {
grunt.config.merge({
watch: {
A: {
files: "js/dev/**/*.coffee",
tasks: ["coffee", "requirejs"]
}
}
});
grunt.task.run('watch');
});
grunt.registerTask('watch-forDev', function () {
grunt.config.merge({
watch: {
B: {
files: "js/dev/**/*.coffee",
tasks: ["coffee"]
}
}
});
grunt.task.run('watch');
});
grunt.registerTask("prod", ["watch-forProd"]);
grunt.registerTask("dev", ["watch-forDev"]);