Skip to content

Instantly share code, notes, and snippets.

@sayanriju
Last active August 18, 2016 05:31
Show Gist options
  • Save sayanriju/1ab405d4553231264858d0df4d39002f to your computer and use it in GitHub Desktop.
Save sayanriju/1ab405d4553231264858d0df4d39002f to your computer and use it in GitHub Desktop.
A Gulp config file for Express using goodies like livereload, nodemon & css minification
// Dependencies
var gulp = require('gulp');
var nodemon = require('gulp-nodemon');
var notify = require('gulp-notify');
var livereload = require('gulp-livereload');
// Task
gulp.task('server', function() {
// listen for changes
livereload.listen();
// configure nodemon
nodemon({
// the script to run the app
// exec: 'node-inspector & node --debug',
nodeArgs: ['--debug'],
script: 'bin/www',
ext: 'js ejs json css html',
"ignore": ["public/*"],
}).on('restart', function(){
// when the app has restarted, run livereload.
gulp.src('*.*')
.pipe(livereload({ start: true }))
// .pipe(notify('Restarted Server & Reloading page...'));
})
});
gulp.task('client', function() {
gulp.src('public/**/*.{js,css,html}')
.pipe(livereload({ start: true }));
});
gulp.task('watch', function() {
livereload.listen();
gulp.watch('public/**/*.{js,css,html}', ['client']);
});
gulp.task('default', ['watch', 'server']);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment