elzi
elzi

Reputation: 5672

gulp-imagemin - how to disregard directory structures?

I'm using gulp-imagemin in it's basic form

gulp.task('image', function() {

  return gulp.src('./images/*')
    .pipe(imagemin({
        progressive: true,
        svgoPlugins: [{removeViewBox: false}],
        use: [pngquant()]
    }))
    .pipe(gulp.dest('./build/'));

});

My images/ directory looks like

 images/
   logo.png

   subfolder/
     image.png

I would like them to output as such:

 build/
   logo.png
   image.png

But they are retaining their folder structure.

How can this be achieved?

Upvotes: 1

Views: 322

Answers (1)

elzi
elzi

Reputation: 5672

I was able to achieve this with gulp-flatten by adding .pipe(flatten()) after the .imagemin()

Upvotes: 1

Related Questions