Skip to content

Instantly share code, notes, and snippets.

@joeyfigaro
Created January 25, 2017 23:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joeyfigaro/bbc33897353f48846869bec3298e2b3f to your computer and use it in GitHub Desktop.
Save joeyfigaro/bbc33897353f48846869bec3298e2b3f to your computer and use it in GitHub Desktop.
Snippet for reloading gulp process when gulpfile.js is updated
//
// 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