1

This question, I believe, can be applied to a variety of grunt tasks. I will use grunt-contrib-coffee in my example.

I have a dev directory with a complex file structure and a bunch of coffee files. When developing, I use this coffee task to copy all the files to a srv_dev directory.

coffee:
  srv_dev:
    files: [
      cwd: 'dev/'
      src: ['**/*.coffee', '!bower_components/**']
      dest: 'srv_dev/'
      expand: true
      ext: '.js'
    ]
    options:
      bare: true
      sourceMap: true

This keeps the structure intact and works okay, except that whenever I modify a file, it triggers a watch task which re-runs the coffee task. So every time I modify any one file, all of my coffee files are moved and re-compiled.

Is it possible to compile, and copy to a new directory, only the coffee files that are modified, while keeping the original directory structure?

dezman
  • 18,087
  • 10
  • 53
  • 91
  • [This might be what I'm looking for.](http://stackoverflow.com/a/19737638/1388017) Also [this](http://stackoverflow.com/questions/15076533/how-can-i-use-grunt-regarde-with-grunt-contrib-coffee-to-only-compile-changed-c?rq=1) and [this.](http://stackoverflow.com/questions/16788731/grunt-watch-multiple-files-compile-only-changed?rq=1) Apparently I should've googled more. – dezman Jan 31 '14 at 00:16

1 Answers1

0

This is the best answer, upvote @Norris.

It uses grunt-newer and is easy as pie.

Community
  • 1
  • 1
dezman
  • 18,087
  • 10
  • 53
  • 91