1

我有一份咖啡文件。如果我改变它,只有那个应该被编译

watch:

    compile:
        files: ['**.coffee']
        tasks: ['coffee:compile']
        option: 
            nospawn: true


coffee:
    compile: ['*.coffee']               

grunt.event.on 'watch', (action,filepath)->
    grunt.config ['coffee','compile'],filepath

上面的配置来自https://github.com/gruntjs/grunt-contrib-watch 但它不起作用。

4

1 回答 1

0

You have 2 different questions here.

Regarding the question in the title of your question:
You can't compile only one file if it changed. However, you may reduce the set of matched files in a watch target.

Regarding the question in the body of your question:
I suppose that in the folllowing line:

files: ['**.coffee']

It should be:

files: ['**/*.coffee']
// or
files: ['*.coffee']

I believe that ** is a wildcard only for directories which don't work with files.
So, try one of my suggestions.

于 2013-06-10T18:04:03.707 回答