1
votes

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?

1
This might be what I'm looking for. Also this and this. Apparently I should've googled more. - dezman

1 Answers

0
votes

This is the best answer, upvote @Norris.

It uses grunt-newer and is easy as pie.