2012-10-10 57 views
8

我是新來gruntjs,這裏是我的簡單gruntfile:使用gruntjs,如何監視.coffee文件中的更改?

/* global module:false */ 
module.exports = function(grunt) { 

    // Project configuration. 
    grunt.initConfig({ 
    watch: { 
     tasks: 'coffee' 
    }, 
    coffee: { 
     compile: { 
     files: { 
      'js/javascript/*.js': ['js/coffeescript/*.coffee'] // 1:1 compile 
     } 
     } 
    } 
    }); 

    grunt.loadNpmTasks('grunt-contrib-coffee'); 

    // Default task. 
    grunt.registerTask('default', 'coffee'); 
}; 

當我運行咕嚕它編譯罰款。但是,當我運行grunt watch時,它只是在等待,沒有檢測到我的更改。

+0

你試圖定義 「...任務: '咖啡-w' ......」? – robkuz

回答

12

您應該添加的文件看:

watch: { 
    coffee: { 
    files: ['js/coffeescript/*.coffee'], 
    tasks: 'coffee' 
    } 
} 

example

+0

工作。謝謝。還有一個問題,在編譯的js文件夾中保留咖啡文件夾的文件夾結構而不必列出應用程序的所有coffeescript文件夾的語法是什麼? – ontk

+0

它可以用Grunt,v0.4a的不穩定alpha版本完成,但它仍在討論中。看看這個主題:https://github.com/gruntjs/grunt-contrib-coffee/pull/1 –

相關問題