我有以下的Gruntfile.coffee。我正在監視如下所示的監視任務以查看文件更改,然後將更改的文件編譯爲coffee-script。grunt-contrib-watch的監測子任務
# Watch task
watch:
coffee:
files: ['client/**/*.coffee','server/**/*/.coffee']
options:
nospawn: true
livereload: true
# Watch changed files
grunt.event.on 'watch', (action, filepath) ->
cwd = 'client/'
filepath = filepath.replace(cwd,'')
grunt.config.set('coffee',
changed:
expand: true
cwd: cwd
src: filepath
dest: 'client-dist/'
ext: '.js'
)
grunt.task.run('coffee:changed')
但是,我想添加另一個監視任務來複制文件,而不是咖啡文件。我將如何監控這些變化?
我想這樣做
# Watch copy task
grunt.event.on 'watch:copy', (action,filepath) -> ...
# Watch coffee task
grunt.event.on 'watch:coffee', (action,filepath) -> ...
的,但似乎並沒有工作。想法?
這有助於 - https://gist.github.com/luissquall/5408257 – imrane 2013-05-13 03:45:16