2015-11-06 80 views
1

我在node.js中有一個web應用程序,我想從nodemon開始,所以每次主腳本更改時,webapp都可以重新啓動。 同時,我有我的咖啡腳本文件,我需要重新編譯每次他們任何一個變化。 我已經設置了一個grunt-contrib-watch任務來偵聽app/frontend/*.coffee文件,以分派咖啡分析器。 但是,由於nodemon任務也在監聽,因此這看起來似乎沒有發生。 我在nodemon ignore中設置了​​文件夾。 我也設置了nodemon並監視爲併發。 不過,每次我編輯咖啡腳本時,咖啡任務都不會執行。如何讓grunt watch和grunt nodemon一起工作

這是我Gruntfile

module.exports = function(grunt) { 

    // Project configuration. 
    grunt.initConfig({ 
    concurrent: { 
     dev: [ 
      'nodemon', 
      'watch' 
     ], 
     options: { 
      logConcurrentOutput: true 
     } 
    }, 
    coffee: { 
     compile: { 
     files: { 
      'app/public/app.js': ['app/frontend/*.coffee'] 
     } 
     } 
    }, 
    nodemon: { 
     dev: { 
     script: 'app/index.js', 
     options: { 
      ignore: ['app/frontend/**', 'app/public/**'] 
     } 
     } 
    }, 
    watch: { 
     scripts: { 
     files: 'app/frontend/*.coffee', 
     tasks: ['coffee'], 
     options: { 
      spawn: false 
     } 
     } 
    } 
    }); 

    grunt.loadNpmTasks('grunt-concurrent'); 
    grunt.loadNpmTasks('grunt-contrib-coffee'); 
    grunt.loadNpmTasks('grunt-contrib-watch'); 
    grunt.loadNpmTasks('grunt-nodemon'); 

    // Default task(s). 
    grunt.registerTask('default', ['coffee', 'nodemon', 'watch']); 

}; 

回答

2

你Gruntfile指示咕嚕運行nodemonwatch依次爲默認的任務(因此watch永遠不會運行爲nodemon從未完成)。

你需要明確包括最後一行concurrent任務:

grunt.registerTask('default', ['coffee', 'concurrent']);