title: How can I make Grunt.js imagemin to track *any* folder and possibly store images in one place?
body: <p>I'm relatively new to Grunt.js, setting up is quiet easy, but now I have 2 issues:
  1) First, how do you track <em>any</em> folder inside a given sources folder? For example, images folder may itself contain images, as well as folders with images and folders with folders with images etc.
  2) Is there a way to watch for images in it's primary (build) folder? Without any forever loop...</p>
  
  <p>Here's my current config:</p>
  
  <pre><code>module.exports = function(grunt) {
  grunt.initConfig({
      jsDir: 'sources/js/',
      jsDistDir: 'public/js/',
      cssDir: 'sources/css/',
      cssDistDir: 'public/css/',
      concat: {
          js: {
              src: ['&lt;%=jsDir%&gt;*.js'],
              dest: '&lt;%=jsDistDir%&gt;javascript.js'
          },
          css: {
              src: ['&lt;%=cssDir%&gt;*.css'],
              dest: '&lt;%=cssDistDir%&gt;styles.css'
          }
      },
      min: {
          dist: {
              src: ['&lt;%= concat.js.dest %&gt;'],
              dest: '&lt;%=jsDistDir%&gt;javascript.js'
          }
      },
      cssmin: {
          dist: {
              src: ['&lt;%= concat.css.dest %&gt;'],
              dest: '&lt;%=cssDistDir%&gt;styles.css'
          }
      },
      imagemin: {
          dynamic: {
              files: [{
                  expand: true,
                  cwd: 'sources/images/',
                  src: ['**/*.{png,jpg,gif}'],
                  dest: 'public/images/'
              }]
          }
      },
      watch: {
          min: {
              files: ['&lt;%=jsDir%&gt;*.js'],
              tasks: ['concat:js', 'min']
          },
          cssmin: {
              files: ['&lt;%=cssDir%&gt;*.css'],
              tasks: ['concat:css', 'cssmin']
          },
          imagemin: {
              files: ['sources/images/**/*.{png,jpg,gif}'],
              tasks: ['imagemin']
          }
      }
  });
  
  grunt.loadNpmTasks('grunt-contrib-concat');
  grunt.loadNpmTasks('grunt-yui-compressor');
  grunt.loadNpmTasks('grunt-contrib-imagemin');
  grunt.loadNpmTasks('grunt-contrib-watch');
  
  grunt.registerTask('default', [
      'concat',
      'min',
      'cssmin',
      'imagemin',
      'watch'
  ]);
  };
  </code></pre>
  
  <p>Thanks!</p>