在gulp.watch中排除子目录

jrh*_*cks 15 javascript node.js gulp

我想看所有文件深深嵌套在模板中,但在构建后排除任何文件夹.

所以排除目录,如:

  • ./templates/foo/build/**/*

  • ./templates/bar/build/**/*

包括目录和文件,如:

  • ./templates/foo/template.html

  • ./templates/foo/css/**/*

  • ./templates/bar/template.html

  • ./templates/bar/css/**/*

目前我成功地列出了子子文件夹名称和子子文件类型

gulp.watch(['templates/*/*.html','templates/*/*.js',
            'templates/*/*.json','templates/*/css/**/*',
            'templates/*/js/**/*'], ['build_templates']);
Run Code Online (Sandbox Code Playgroud)

但我真的希望每次添加特定的子子文件夹或子子文件类型时都能够停止更新表达式.怎么能包括除了?

Bal*_*zar 19

我认为您可以尝试build使用!符号排除子目录.

想想这样的事情,根据您的需求进行调整:

gulp.watch([
 'templates/**/*',
 '!templates/*/{build,build/**}'
], ['build_templates'])
Run Code Online (Sandbox Code Playgroud)

你也可以看看Gulp Ignore.


Bam*_*ieh 5

我知道这是旧的,但你应该排除的文件夹所有的文件夹里面藏汉不包括单独的文件夹不工作。

gulp.watch(['templates/**/*','!templates/{foo, bar}/build/**/*'], ['build_templates']);
Run Code Online (Sandbox Code Playgroud)