Skip to content

Instantly share code, notes, and snippets.

@mohayonao
Created March 26, 2013 00:29
Show Gist options
  • Save mohayonao/5242156 to your computer and use it in GitHub Desktop.
Save mohayonao/5242156 to your computer and use it in GitHub Desktop.
gruntで更新のあったファイルだけ処理する
module.exports = (grunt)->
'use strict'
GRUNT_CHANGED_PATH = '.grunt-changed-file'
if grunt.file.exists GRUNT_CHANGED_PATH
changed = grunt.file.read GRUNT_CHANGED_PATH
grunt.file.delete GRUNT_CHANGED_PATH
changed_only = (file)-> file is changed
else
changed_only = -> true
data = {}
grunt.initConfig
watch:
jade:
files: 'public/**/*.jade'
tasks: 'jade'
stylus:
files: 'public/**/*.styl'
tasks: 'stylus'
coffee:
files: 'public/**/*.coffee'
tasks: 'coffee'
jade:
files:
expand : true
src : 'public/**/*.jade'
options: data: data
ext : '.html'
filter : changed_only
stylus:
files:
expand : true
src : 'public/**/*.styl'
ext : '.css'
filter : changed_only
coffee:
files:
expand : true
src : 'public/**/*.coffee'
ext : '.js'
filter : changed_only
grunt.loadNpmTasks 'grunt-contrib-watch'
grunt.loadNpmTasks 'grunt-contrib-jade'
grunt.loadNpmTasks 'grunt-contrib-stylus'
grunt.loadNpmTasks 'grunt-contrib-coffee'
grunt.event.on 'watch', (action, changed)->
if action is 'changed'
if not /(layout)/.test changed
grunt.file.write GRUNT_CHANGED_PATH, changed
grunt.registerTask 'default', ['watch']
grunt.registerTask 'build' , ['jade', 'stylus', 'coffee']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment