問題描述
我希望能夠將 gulp
中的 watch
任務添加到 frontend 中的所有
和下面的任何其他 js 文件js
文件中/js
I'd like to be able to add a watch
task in gulp
to all of the js
files in the frontend/js
and any other js files below
gulp.watch('./frontend/js/**/*.js', ['browserify']);
這只會針對 js
一個文件夾深處的文件
This will only target js
files one folder deep
推薦答案
應該匹配任意數量的子目錄:
It's supposed to match any number of subdirectories:
**
如果globstar"在路徑部分中單獨存在,則它匹配零個或多個目錄和子目錄以搜索匹配項.它不會抓取符號鏈接的目錄.
**
If a "globstar" is alone in a path portion, then it matches zero or more directories and subdirectories searching for matches. It does not crawl symlinked directories.
https://github.com/isaacs/node-glob
那里有符號鏈接目錄嗎?
Do you have symlinked directories in there?
我認為您不會通過 gulp 原生遍歷您的符號鏈接目錄.我建議你看看 node.js fs.readdir 遞歸目錄搜索 看看這些解決方案是否可以應用于您的用例.問題或答案中沒有任何內容專門針對符號鏈接,所以我不知道那里是否有適合您的解決方案.如果您可以使用其中一種解決方案獲得一組取消引用的路徑名,那么您只需將該數組傳遞給 gulp.src()
.
I don't think you'll get gulp to natively traverse your symlinked directories. I recommend you take a look at node.js fs.readdir recursive directory search and see if any of those solutions can be applied to your use case. Nothing in the question or answers specifically addresses symlinks, so I don't know if there's a solution for you there or not. If you can get an array of dereferenced pathnames using one of those solutions, then you can just pass the array to gulp.src()
.
這篇關于Gulp - 定位文件夾及其子文件夾中的所有文件的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!