1

What I would like is the watcher to watch any newly added images and compress ONLY the newly added ones. I would also want it to remove the images I remove from the uncompressed folder (which is images/images/), also in the compressed one which is (images/build/), but this doesn't happen.

What happens now is, anytime I add an image, Grunt recompresses them all (as in this screenshot:

enter image description here

where I added two new images, and it recompresses the whole folder) and if I remove an image from the uncompressed folder, grunt keeps them in the compressed one.

Here's chunks of my gruntfile:

  • the task

    imagemin : {
        dynamic : {
            files : [{
                expand : true,
                cwd : 'images/images/',
                src : ['**/*.{png,jpg,gif}'],
                dest : 'images/build/'
            }]
        }
    }, //end imagemin
    
  • the watcher part:

    images : {
        files : ['images/images/*.{png,jpg,gif}'],
        tasks : ['imagemin'],
        options : {
            spawn : false,
        }
    }
    

do I need an additional plugin to do this? thanks in advance!

Jason Aller
  • 3,541
  • 28
  • 38
  • 38
valerio0999
  • 11,458
  • 7
  • 28
  • 56

1 Answers1

2

you can use
- grunt-newer for detecting updated files : https://github.com/tschaub/grunt-newer
- grunt-delete-sync for synchronize deleted files between two directories https://www.npmjs.org/package/grunt-delete-sync

manu
  • 36
  • 2
  • These links are for libraries which answer directly to both problems. If these libraries disappear, my answer would be useless. – manu Jul 30 '14 at 12:41