Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can you remove a folder structure when copying files in gulp?

Tags:

gulp

If I use :

 gulp.src(['app/client/**/*.html'])   .pipe(gulp.dest('dist')); 

The folder structure in which my .html files were in, is maintained in the dist folder, but I would like to remove the folder structure completely and just a flat hierarchy in my dist folder.

like image 736
i_am_elliot Avatar asked Jul 09 '14 15:07

i_am_elliot


People also ask

How do I copy a directory structure without copying files?

Type "xcopy", "source", "destination" /t /e in the Command Prompt window. Instead of “ source ,” type the path of the folder hierarchy you want to copy. Instead of “ destination ,” enter the path where you want to store the copied folder structure. Press “Enter” on your keyboard.

How do I copy files using Gulp?

var copy = require('gulp-copy'); gulp. task('copy-resources', function() { return gulp. src('./src/img/*. png') .


1 Answers

You could use gulp-rename to accomplish this:

var rename = require('gulp-rename');  gulp.src('app/client/**/*.html')   .pipe(rename({dirname: ''}))   .pipe(gulp.dest('dist')); 
like image 98
Ben Avatar answered Oct 26 '22 15:10

Ben



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!