Skip to content

Instantly share code, notes, and snippets.

@chaosim
Created October 8, 2013 09:29
Show Gist options
  • Save chaosim/6882090 to your computer and use it in GitHub Desktop.
Save chaosim/6882090 to your computer and use it in GitHub Desktop.
watch and run tasks only on changed files
grunt.event.on 'watch', (action, filepath, target) ->
if minimatch filepath, 'src/**/*.coffee'
grunt.config.set 'coffee',
dev:
expand: true
cwd: 'src'
src: filepath.slice(4)
dest: 'dev'
ext: '.js'
else if minimatch filepath, 'src/views/**/*.jade'
grunt.config.set 'jade',
dev:
options: pretty: true
expand: true
cwd: 'src/views'
src: filepath.slice(10)
dest: 'dev/public/views'
ext: '.html'
else
for item in copyDevFiles
if minimatch filepath, item[0]+'/'+item[2]
grunt.config.set 'copy',
dev:
expand: true
dot: true
cwd: item[0]
dest: item[1]
src: filepath.slice(item[0].length+1)
break
@chaosim
Copy link
Author

chaosim commented Oct 8, 2013

watch and run tasks only on changed files

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment