Skip to content

Instantly share code, notes, and snippets.

@Jeff2Ma
Created December 29, 2016 11:16
Show Gist options
  • Select an option

  • Save Jeff2Ma/a20c652cb56c5411bad5f5879b7c4098 to your computer and use it in GitHub Desktop.

Select an option

Save Jeff2Ma/a20c652cb56c5411bad5f5879b7c4098 to your computer and use it in GitHub Desktop.

Revisions

  1. @tilap tilap created this gist Jun 28, 2014.
    24 changes: 24 additions & 0 deletions gulpfile.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,24 @@
    // 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
    })