sindresorhus / gulp-imagemin

Minify PNG, JPEG, GIF and SVG images
MIT License
1.9k stars 157 forks source link

Ignoring .db files sends imagemin into endless loop #322

Closed wgstjf closed 5 years ago

wgstjf commented 5 years ago

Hi guys,

We're using imagemin (^3.1.1) as part of a Wordpress starter theme and within a Windows environment. We need to ignore the Thumbs.db file in the source image folder so have modified the code as follows:

FROM THIS

// Optimize images, move into assets directory
   gulp.task('images', function() {
   return gulp.src(SOURCE.images)
   .pipe(plugin.imagemin())
  .pipe(gulp.dest(ASSETS.images))
});

TO THIS

// Optimize images, move into assets directory
   gulp.task('images', function() {
   return gulp.src(SOURCE.images + '.!(db)')
   .pipe(plugin.imagemin())
  .pipe(gulp.dest(ASSETS.images))
});

The issue is that having done this, though the Thumbs.db error goes away, it now sends imagemin into a infinite loop after successfully minifying the relevant image as shown below:

image

Any help on how to prevent this would be greatly appreciated.

Cheers in advance,

Will

sindresorhus commented 5 years ago

I don't think this is related to gulp-imagemin. It just accepts a stream of file paths. The problem you're having is with Gulp itself.