Can you remove the folder structure when copying files to gulp?

If I use:

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

The folder structure where my .html files were located is stored in the dist folder, but I would like to completely remove the folder structure and only the flat hierarchy in my dist folder.

+55
gulp
Jul 09 '14 at 15:38
source share
2 answers

You can use gulp-rename to accomplish this:

 var rename = require('gulp-rename'); gulp.src('app/client/**/*.html') .pipe(rename({dirname: ''})) .pipe(gulp.dest('dist')); 
+96
Jul 14 '14 at 16:46
source share

You can use gulp -flatten https://www.npmjs.com/package/gulp-flatten

     app
     β”œβ”€β”€ logo
     β”‚ └── logo.styl
     └── sidebar
         └── sidebar.styl
    
     var flatten = require ('gulp-flatten');
     gulp.src ('app / ** / *. styl')
       .pipe (flatten ())
       .pipe (gulp.dest ('dist /'));
    
     dist
     β”œβ”€β”€ logo.styl
     └── sidebar.styl
    
+25
Oct 25 '15 at 12:10
source share



All Articles