title: How do you watch multiple files, but only run task on changed file, in Grunt.js?
body: <p>In learning how to use <a href="https://github.com/cowboy/grunt" rel="noreferrer">grunt</a>, I am trying to make a simple coffee-script watcher/compiler. The problem is, if I tell the <code>watch</code> task to watch several files, and one changes, it is going to pass all of the files to the <code>coffee</code> command. This means when you change 1 file, it's going to recompile <em>all</em> of the files matching the <code>src</code> pattern. Instead, I want to only recompile the single file that changed that matches the <code>src</code> pattern.</p>
  
  <p>Here is the <code>grunt.js</code>:</p>
  
  <pre><code>module.exports = function(grunt) {
    grunt.initConfig({
      coffee: {
        app: {
          src: ['test/cases/controller/*.coffee'],
          dest: 'tmp',
          options: {
            bare: true,
            preserve_dirs: true
          }
        }
      },
      watch: {
        files: ['&lt;config:coffee.app.src&gt;'],
        tasks: ['coffee:app']
      }
    });
  
    grunt.loadNpmTasks('grunt-coffee');
    grunt.registerTask('default', 'coffee');
  };
  </code></pre>
  
  <p>This is using <a href="https://github.com/avalade/grunt-coffee" rel="noreferrer">grunt-coffee</a>, which is basically this: <a href="https://gist.github.com/2373159" rel="noreferrer">https://gist.github.com/2373159</a>.</p>
  
  <p>When I run <code>grunt watch</code>, and I save a file in <code>test/cases/controller/*.coffee</code>, it compiles <em>all</em> of the matching files (putting them in <code>tmp/*</code>).</p>
  
  <p>How do you instead <em>only compile the <strong>changed</strong> file</em> using grunt?</p>