Dan-Nolan提出了一个问题:Modify file in place (same dest) using Gulp.js and a globbing pattern,或许与您遇到的问题类似。
回答者numbers1311407给出了该问题的处理方式:
As you suspected, you are making this too complicated. The destination doesn't need to be dynamic as the globbed path is used for the dest
as well. Simply pipe to the same base directory you're globbing the src from, in this case "sass":
gulp.src("sass/**/*.scss") .pipe(sass()) .pipe(gulp.dest("sass"));
If your files do not have a common base and you need to pass an array of paths, this is no longer sufficient. In this case, you'd want to specify the base option.
var paths = [ "sass/**/*.scss", "vendor/sass/**/*.scss" ]; gulp.src(paths, {base: "./"}) .pipe(sass()) .pipe(gulp.dest("./"));
希望本文对你有帮助,欢迎支持JavaScript中文网