我有以下 Gruntfile.coffee。我正在监视监视任务,如下所示以查看文件更改,然后将更改的文件编译为咖啡脚本。
# 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) -> ...
但这似乎不起作用。想法?