Gruntjs 同时使用grunt contrib less和grunt nodemon

Gruntjs 同时使用grunt contrib less和grunt nodemon,gruntjs,nodemon,Gruntjs,Nodemon,似乎当nodemon运行时,其他任务将被挂起而不运行。我怎么能同时使用它们呢?或者我是否可以使用nodemon来监视更少的文件并编译它们 这是我的Grunfile.js: module.exports = function(grunt) { // Project configuration. grunt.initConfig({ nodemon: { dev: { options: {

似乎当nodemon运行时,其他任务将被挂起而不运行。我怎么能同时使用它们呢?或者我是否可以使用nodemon来监视更少的文件并编译它们

这是我的Grunfile.js:

module.exports = function(grunt) {

    // Project configuration.
    grunt.initConfig({
        nodemon: {
            dev: {
                options: {
                    file: 'app.js',
                    nodeArgs: ['--debug'],
                    env: {
                        PORT: '3000'
                    }
                }
            }
        },
        less: {
            development: {
                options: {
                    paths: ['./public/less'],
                    yuicompress: true
                },
                files: {
                    './public/css/test.css': './public/less/test.less'
                }
            }
        },
        watch: {
            files: "./public/less/*.less",
            tasks: ['less']
        }
    });


    grunt.loadNpmTasks('grunt-contrib-watch');
    grunt.loadNpmTasks('grunt-contrib-less');
    grunt.loadNpmTasks('grunt-nodemon');

    grunt.registerTask('default', ['less','watch']);
};

您正在寻找的是grunt并发,这是一个允许您异步运行多个任务的任务,它非常常见于阻塞任务,如watch或nodemon

至于nodemon,这方面的一个主要示例直接位于grunt nodemon的github页面上,在“高级使用”部分下使用grunt并发


希望这就是你要找的。

嗯。。。您可能需要在不同的终端中运行
grunt节点mon
grunt watch
任务。他们都坐着等待改变,所以我不知道一个怎么能和另一个同时运行。