Created
January 25, 2017 23:11
-
-
Save joeyfigaro/bbc33897353f48846869bec3298e2b3f to your computer and use it in GitHub Desktop.
Snippet for reloading gulp process when gulpfile.js is updated
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
// | |
// gulpfile.babel.js | |
// | |
import { spawn } from 'child_process'; | |
function autoload() { | |
let process; | |
const spawnChildren = e => { | |
if (process) process.kill(); | |
return process = spawn('gulp', 'default', { stdio: 'inherit' }); | |
} | |
return gulp.watch(path.resolve(__dirname, 'gulpfile.babel.js'), spawnChildren); | |
} | |
gulp.task('autoload', autoload); | |
gulp.task('default', [...]); | |
// | |
// Package.json | |
// | |
scripts: { | |
"start": "gulp autoload" | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment