I'm trying to to a gulp task which copies all files inside a folder to another folder
gulp.task('copy-fonts', ['unzip'], function() {
return gulp.src('./gulp-tmp/**/fonts/*')
.pipe(gulp.dest('fonts'));
});
The problem is, the name of the directory after gulp-tmp
varies, so I had to use **
there.
So the result ends up like /fonts/[randomFolderName]/fonts/[the files]
Where what I want is /fonts/[the files]
Use gulp-flatten.
var flatten = require('gulp-flatten');
gulp.src('./gulp-tmp/**/fonts/*')
.pipe(flatten())
.pipe(gulp.dest('fonts'));
I use simple code without external libs, for example:
gulp.src('./src/fonts/*.{ttf,woff,eof,svg}')
.pipe(gulp.dest('/build/fonts'));
or only html files:
gulp.src('./src/templates/*.html')
.pipe(gulp.dest('/build/templates'));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With