How to run two grunt watch tasks simultaneously

前端 未结 9 1037
情歌与酒
情歌与酒 2020-12-12 16:29

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

相关标签:
9条回答
  • 2020-12-12 16:50

    Concurrent works fine for me

    concurrent: {
                options: {
                    logConcurrentOutput: true
                },
                set1: ['watch:html', 'watch:styles'],
            },
    
    grunt.registerTask('default', 'watch');
    grunt.registerTask('htmlcss', ['concurrent:set1']);
    
    0 讨论(0)
  • 2020-12-12 16:51

    Without worrying grunt.registerTask() in Gruntfile.js, I sometimes run grunt as background processes by typing the following in the command line:

    $ grunt watch:A &
    $ grunt watch:C &
    

    You can make the commands as a batch script for more convenience. Hopefully it helps.

    0 讨论(0)
  • 2020-12-12 16:52

    I've found using grunt-concurrent works:

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

    Then:

    grunt.registerTask("prod", ["concurrent:prod"]);
    grunt.registerTask("dev", ["concurrent:dev"]);
    
    0 讨论(0)
提交回复
热议问题