gulp-imagemin - 如何忽略目录结构? [英] gulp-imagemin - how to disregard directory structures?

查看:175
本文介绍了gulp-imagemin - 如何忽略目录结构?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我以

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/'));

});

我的 images / 目录看起来像 p>

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?

推荐答案

我能够通过吞食谷物实现这一目标。通过在 .imagemin()

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

这篇关于gulp-imagemin - 如何忽略目录结构?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆