0

I'm using grunt-contrib-imagemin to optimize my images on a project. However, the optimization takes a long time due to the amount of images I'm optimizing.

Therefore, I only want to optimize images which are not existing in the destination OR where the source file is newer then the destination file.

Here is my configuration:

imagemin: {
  dist: {
    files: [{
      expand: true,
      cwd: 'src',
      src: ['**/*.{jpg,jpeg,png,gif}'],
      dest: 'dist/',
      filter: 'isFile'
    }]
  }
}

Is there any way to extend the expansion of files to exclude already existing or newer destination files from the preprocessing?

Vincent
  • 2,342
  • 1
  • 17
  • 22
  • take a look here : http://stackoverflow.com/questions/16788731/grunt-watch-multiple-files-compile-only-changed – Catalyst Jun 29 '14 at 17:21

1 Answers1

1

Use grunt-newer https://github.com/tschaub/grunt-newer

watch: {
    imagemin: {
        files: ['**/*.{jpg,jpeg,png,gif}'],
        tasks: ['newer:imagemin']
    }
}
Sean
  • 779
  • 6
  • 18