1

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

这是我的 Gruntfile.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']);
};
4

1 回答 1

2

您正在寻找的是 grunt-concurrent,这是一项允许您异步运行多个任务的任务,并且对于诸如 watch 或 nodemon 之类的阻塞任务非常常见。

https://github.com/sindresorhus/grunt-concurrent

至于 nodemon,一个典型的例子直接位于 grunt-nodemon 的 github 页面上,在“高级用法”部分下使用 grunt-concurrent。

https://github.com/ChrisWren/grunt-nodemon#advanced-usage

希望这就是你要找的。

于 2014-01-23T20:10:25.827 回答