Skip to content

Instantly share code, notes, and snippets.

@melihovv
Created June 18, 2015 20:57
Show Gist options
  • Save melihovv/e6f447400f689fbf639f to your computer and use it in GitHub Desktop.
Save melihovv/e6f447400f689fbf639f to your computer and use it in GitHub Desktop.
Gulpfile to reload server and browser during development.
var gulp = require('gulp');
var nodemon = require('gulp-nodemon');
var livereload = require('gulp-livereload');
gulp.task('default', function () {
livereload.listen();
nodemon({
// Main script.
script: 'app.js',
// File extensions to watch.
ext: 'js hbs',
// Directories to watch.
watch: [
'models',
'controllers',
'views',
'.'
],
// Don't output to console.
// Output is in the next method.
stdout: false
}).on('readable', function () {
this.stdout.on('data', function (chunk) {
// If stream contain 'listening'...
if (/listening/.test(chunk.toString())) {
// Reload page.
livereload.reload()
}
// Make output to console.
process.stdout.write(chunk)
})
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment