Within Gulp, I am using gulp.src
to select every font file from a directory:
gulp.task(\'copy-fonts\', function() {
gulp.src(\'components/**/
Another option is to simply rewrite the file path inside 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';
}));
});
You can also use this technique with 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));
});