Grunt globbing模式在grunt-contrib-watch中没有按预期工作

时间:2013-10-16 10:37:45

标签: gruntjs glob grunt-contrib-watch

grunt-contrib-watch 中,我想留意<%%= yeoman.app %>/*.html中的更改以及更深层次的任何HTML文件的更改。

因此,我的监视任务如下所示:

watch: {
    html: {
        files: ['<%%= yeoman.app %>/{,*/}*.html'],
        tasks: ['copy:html', 'replace', 'processhtml:dev']
    }
},

当我将更改保存到<%%= yeoman.app %>/index.html时,监视任务按预期运行。但是,当我在<%%= yeoman.app %>内创建目录,然后在该新目录中创建newfile.html时, watch 不会被解雇。

我还尝试了files: ['<%%= yeoman.app %>/*.html', '<%%= yeoman.app %>/*/*.html'],甚至files: ['<%%= yeoman.app %>/**/*.html']来匹配所有子目录,但是当子目录中的HTML文件被编辑时, watch 仍然不会触发

我错过了什么?

1 个答案:

答案 0 :(得分:1)

我认为你的下划线模板格式不正确。试试这个:

files: ['<%= yeoman.app %>/**/*.html']

运行grunt watch --verbose将为您提供该任务将要监视的所有文件的列表。确保您希望观看的路径在那里。