Created
December 29, 2016 11:16
-
-
Save Jeff2Ma/a20c652cb56c5411bad5f5879b7c4098 to your computer and use it in GitHub Desktop.
Gulp reload on gulpfile.js change
This file contains 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
// Gulp restart when gulpfile is changed | |
var spawn = require('child_process').spawn; | |
gulp.task('gulp-autoreload', function() { | |
// Store current process if any | |
var p; | |
gulp.watch('gulpfile.js', spawnChildren); | |
// Comment the line below if you start your server by yourslef anywhere else | |
spawnChildren(); | |
function spawnChildren(e) { | |
if(p) { | |
p.kill(); | |
} | |
p = spawn('gulp', ['build'], {stdio: 'inherit'}); | |
} | |
}); | |
gulp.task('build', function() { | |
// Your stuff here with build | |
// Moreover, it's a good idea to have livereload if necessary | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment