【问题标题】:Use both grunt-contrib-less and grunt-nodemon同时使用 grunt-contrib-less 和 grunt-nodemon
【发布时间】:2014-01-23 21:21:30
【问题描述】:

似乎当 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']);
};

【问题讨论】:

  • 嗯...您可能需要在单独的终端中运行 grunt nodemongrunt watch 任务。他们都坐着等待变化,所以我不知道一个人怎么能和另一个人同时运行。

标签: gruntjs nodemon


【解决方案1】:

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

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

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

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

希望这就是你要找的。​​p>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-04-30
    • 1970-01-01
    • 2014-11-19
    • 2014-02-24
    • 1970-01-01
    • 2015-02-02
    • 2015-01-25
    相关资源
    最近更新 更多