How to run two grunt watch tasks simultaneously

前端 未结 9 1039
情歌与酒
情歌与酒 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:40

    EDIT: concurrent now has a logConcurrentOutput option! More info here: https://github.com/sindresorhus/grunt-concurrent#logconcurrentoutput.

    Watch is a weirdly concurrent but blocking task, so you have to be creative to get multitask-like functionality working.

    Concurrent loses all output from the watch tasks, which isn't ideal.

    Try dynamically writing the config object in a custom task:

    grunt.registerTask('watch:test', function() {
      // Configuration for watch:test tasks.
      var config = {
        options: {
          interrupt: true
        },
        unit: {
          files: [
            'test/unit/**/*.spec.coffee'
          ],
          tasks: ['karma:unit']
        },
        integration: {
          files: [
            'test/integration/**/*.rb',
            '.tmp/scripts/**/*.js'
          ],
          tasks: ['exec:rspec']
        }
      };
    
      grunt.config('watch', config);
      grunt.task.run('watch');
    });
    

提交回复
热议问题