我正在尝试使用gulp.src()
覆盖所有文件和目录,以及以字符_
开头的所有目录(即_Stuff/
)。我怎样才能做到这一点?
答案 0 :(得分:8)
假设您有一个包含以下文件的文件夹project/src
:
file.txt
folder
folder/file.txt
folder/_subfolder
folder/_subfolder/file.txt
folder/subfolder
folder/subfolder/file.txt
_folder
_folder/file.txt
_folder/_subfolder
_folder/_subfolder/file.txt
_folder/subfolder
_folder/subfolder/file.txt
然后在project/Gulpfile.js
中执行此任务:
gulp.task('default', function() {
return gulp.src([
'src/**/*', //select all files
'!src/**/_*/', //exclude folders starting with '_'
'!src/**/_*/**/*', //exclude files/subfolders in folders starting with '_'
])
.pipe(gulp.dest('dist'));
});
将导致以下文件写入project/dist
:
file.txt
folder
folder/file.txt
folder/subfolder
folder/subfolder/file.txt