Last active
December 22, 2015 18:49
-
-
Save bittersweetryan/6515680 to your computer and use it in GitHub Desktop.
This Grunt config will only run a task on the file that has triggered the watch plugin.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
automatically sync files from the deploy directory back to the source directory | |
*/ | |
module.exports = function( grunt ){ | |
grunt.initConfig( { | |
copy : { | |
main: { | |
files : [ | |
] | |
} | |
}, | |
watch : { | |
js : { | |
files : [ | |
getDirForType( 'js', 'web' ) | |
], | |
tasks : [ | |
'copy' | |
], | |
options : { | |
spawn : false | |
} | |
} | |
} | |
} ); | |
grunt.event.on( 'watch', function( action, filepath, taskName ){ | |
var files = grunt.config( 'copy.main.files' ), | |
fileName = new RegExp('/' + taskName + '.+').exec( filepath )[0]; | |
files.push( | |
{ | |
src : filepath, | |
dest : deployDir + fileName | |
} | |
); | |
grunt.config( 'copy.main.files', files ); | |
} ); | |
require( 'matchdep' ).filterDev( 'grunt-*' ).forEach( grunt.loadNpmTasks ); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment