gulp-imagemin - how to disregard directory structures?

拟墨画扇 提交于 2019-12-12 06:05:38

问题


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?


回答1:


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



来源:https://stackoverflow.com/questions/27712566/gulp-imagemin-how-to-disregard-directory-structures

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!