如何使用Grunt的concurrent模块?

3

我正在使用Grunt并行任务插件

 grunt.initConfig({
                  concurrent: {
                    options: {
                        logConcurrentOutput: true
                   },
                  prod: {
                       tasks: ["watch:A", "watch:C"]
                  },
                  dev: {
                     tasks: ["watch:B", "watch:C"]
                  }
                  }
              });
             grunt.loadNpmTasks('grunt-concurrent');
             grunt.registerTask("prod", ["concurrent:prod"]);
             grunt.registerTask("dev", ["concurrent:dev"]);
             grunt.tasks(['dev'], {}, function(args) {



});

我遇到了一个错误,它不能正常执行。

 Running "concurrent:dev" (concurrent) task

      Usage: sails [command]

      Commands:

        version               
        lift [options]        
        new [options] [path_to_new_app]
        generate              
        console               
        consle                
        consloe               
        c                     
        www                   
        debug                 
        configure             
        help                  

      Options:

        -h, --help     output usage information
        -v, --version  output the version number
        --silent       
        --verbose      
        --silly        


      Usage: sails [command]

      Commands:

        version               
        lift [options]        
        new [options] [path_to_new_app]
        generate              
        console               
        consle                
        consloe               
        c                     
        www                   
        debug                 
        configure             
        help                  

      Options:

        -h, --help     output usage information
        -v, --version  output the version number
        --silent       
        --verbose      
        --silly        
    Done, Without errors.

我有这个输出,我需要使用grunt-concurrent逐个正确地执行任务。你能帮我吗?你能给一些代码吗?如何通过concurrent运行自定义任务?
1个回答

0

这里有一个可行的例子。希望能对你有所帮助!

module.exports = function(grunt) {

    grunt.initConfig({
       nodemon: {
           dev: {
               script: 'server.js'
           }
       },

        jshint: {
            files: ['Gruntfile.js', 'app/views/js/**/*.js', 'test/**/*.js'],
            options: {
                globals: {
                    jQuery: true
                }
            }
        },

        watch: {
            files: ['<%= jshint.files %>'],
            tasks: ['jshint']
        },

       concurrent: {
            options: {
                logConcurrentOutput: true
            },
            tasks: ['nodemon','watch']
        }
    });

    grunt.loadNpmTasks('grunt-contrib-jshint');
    grunt.loadNpmTasks('grunt-nodemon');
    grunt.loadNpmTasks('grunt-contrib-watch');
    grunt.loadNpmTasks('grunt-concurrent');
    grunt.registerTask('default',['concurrent', 'jshint']);
};

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接