Skip to content

Instantly share code, notes, and snippets.

@al-the-x
Last active August 29, 2015 14:08
Show Gist options
  • Save al-the-x/77c08f8ea218ab2613b9 to your computer and use it in GitHub Desktop.
Save al-the-x/77c08f8ea218ab2613b9 to your computer and use it in GitHub Desktop.
Sample gulpfile for live reload...
var gulp = require('gulp'),
connect = require('gulp-connect'),
args = require('yargs')
.alias('p', 'path')
.demand(['path'])
.alias('w', 'watch')
.argv;
gulp.task('connect', function(){
connect.server({
root: args.path,
livereload: true
});
});
gulp.task('livereload', function(){
gulp.src(args.watch)
.pipe(connect.reload());
});
gulp.task('watch', function(){
args.watch && gulp.watch([ args.watch ], [ 'livereload' ]);
});
gulp.task('open', function(){
require('child_process').exec('open http://localhost:8080');
});
gulp.task('default', ['connect', 'watch', 'open']);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment