如何在子文件夹中监听文件? [英] How grunt watch files in sub folders?
本文介绍了如何在子文件夹中监听文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的代码文件夹和文件是这样的,你永远不知道它里面有多少个子文件夹:
js / sub1 / a .js
js / sub2 / b.js
js / sub3 / sub31 / c.js
js / sub4 / sub41 / sub411 / d.js
以下是Gruntfile.js的一部分:
grunt.initConfig({
watch:{
src:{
files:['js / *。js'],
tasks:[]
}
}
});
Grunt无法使用'来观察所有JavaScript文件的更改JS / *。JS'
。那么如何编写正确的文件路径表达式呢? 根据关于文件通配的官方文档,要监视目录路径及其子目录中某种文件类型的文件更改,您需要:
档案:['js / ** / *。js']
My codes folders and files like this, you never know how many sub folders in it:
js/sub1/a.js
js/sub2/b.js
js/sub3/sub31/c.js
js/sub4/sub41/sub411/d.js
Here is part of the Gruntfile.js:
grunt.initConfig({
watch: {
src: {
files: ['js/*.js'],
tasks: []
}
}
});
Grunt can't watch the changes of my all JavaScript files by using 'js/*.js'
. So how to write the correct file path expression?
解决方案
Per the official documentation on file globbing, to watch for changes for files of a certain file type in the directory path and its subdirectories, you'll want:
files: ['js/**/*.js']
这篇关于如何在子文件夹中监听文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文