Created
March 22, 2016 01:53
-
-
Save githubhy/b0950903534d54a98e1e to your computer and use it in GitHub Desktop.
gulp+express+nodemon+browerSync -- Restart express server followed by liveload
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
'use strict'; | |
var gulp = require('gulp'); | |
var bs = require('browser-sync'); | |
var nodemon = require('gulp-nodemon'); | |
gulp.task('default', ['browser-sync'], function () { | |
}); | |
gulp.task('browser-sync', ['nodemon'], function() { | |
bs.init(null, { | |
proxy: "http://localhost:3000", | |
port: "5000", | |
files: ["public/**/*.*"], | |
browser: "safari" | |
}); | |
}); | |
gulp.task('nodemon', function (cb) { | |
var started = false; | |
return nodemon({ | |
env: { 'NODE_ENV': 'development' } | |
}).on('start', function () { | |
// to avoid nodemon being started multiple times | |
// thanks @matthisk | |
if (!started) { | |
cb(); | |
started = true; | |
} | |
}).on('restart', function() { | |
setTimeout(function() { | |
console.log('-------- restart BS --------'); | |
bs.reload(); | |
}, 1000); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment