另一种选择是简单地重写里面的文件路径gulp.dest
:
var path = require('path');
gulp.task('copy-fonts', function() {
return gulp.src('components/**/*.{ttf,woff,eof,svg}')
.pipe(gulp.dest(function(file) {
file.path = file.base + path.basename(file.path);
return 'build/fonts';
}));
});
您还可以将此技术用于gulp-changed
:
var path = require('path');
var changed = require('gulp-changed');
gulp.task('copy-fonts', function() {
var dest = 'build/fonts';
return gulp.src('components/**/*.{ttf,woff,eof,svg}')
.pipe(changed(function(file) {
file.path = file.base + path.basename(file.path);
return dest;
}))
.pipe(gulp.dest(dest));
});