Monday 8 May 2017

Use imagemin with last modified date to avoid processing images needlessly

I'm using imagemin in an npm script to optimize images from a /src/ directory into a /dist/. (Successfully)

However, our project has a ton of images. I don't want to blindly run imagemin on a glob pattern like so: ./src/media/**/*.{jpg,png,svg,jpeg} and wait minutes for the script to complete. I'd like to somehow filter the files out by their modified date. If the source (original) hasn't been updated, but the file exists, skip it.

Has anyone tackled this already?



via Markus

No comments:

Post a Comment