javascript 如何 grunt 监视子文件夹中的文件?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15542520/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-27 01:08:54  来源:igfitidea点击:

How grunt watch files in sub folders?

javascriptgruntjs

提问by HOT.CHO

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:

这是 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?

Grunt 无法通过使用'js/*.js'. 那么如何写出正确的文件路径表达式呢?

回答by ashox

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:

根据文件 globbing官方文档,要监视目录路径及其子目录中特定文件类型的文件的更改,您需要:

files: ['js/**/*.js']