5

I'm using Grunt Imagemin to optimize a folder of images. However everytime I run that command, it runs imagemin on ALL of the images. Is there a way to only run grunt imagemin when it detects new changes?

cusejuice
  • 10,285
  • 26
  • 90
  • 145
  • i have the same problem http://stackoverflow.com/questions/24099367/imagemin-for-gruntjs-used-with-watch-for-grunt-not-properly-watching-my-files – valerio0999 Jul 09 '14 at 15:40

1 Answers1

2

Try implementing grunt-newer:

Grunt Task for running tasks if source files are newer only.

Here you can find a short tutorial about how to use it.

After implementing it, you should prepend newer: to the imagemin task.

  • I tried that in combination with watch - watch: {images:{files: ['my_folder/*.{png,jpg,gif}'], tasks: ['newer:imagemin']}} and it worked. Thx! – user2718671 Mar 31 '16 at 08:46