Skip to content

Instantly share code, notes, and snippets.

@vnys
Last active August 29, 2015 14:04
Show Gist options
  • Save vnys/2824b42da5afcf8509bb to your computer and use it in GitHub Desktop.
Save vnys/2824b42da5afcf8509bb to your computer and use it in GitHub Desktop.
Super simple gulp livereload
var gulp = require('gulp');
var connect = require('gulp-connect');
var path = require('path');
var open = require('gulp-open');
var root = 'app', port = 9000;
gulp.task('connect', function() {
connect.server({
root: root,
livereload: true,
port: port
})
})
gulp.task('reload', function() {
gulp.src(root).pipe(connect.reload());
})
gulp.task('watch', function() {
gulp.watch(path.join(root, '**/*'), ['reload'])
})
gulp.task('open', function() {
gulp.src(path.join(root, 'index.html'))
.pipe(open('', { url: 'http://localhost:'+ port }));
})
gulp.task('default', ['connect', 'open', 'watch']);
@vnys
Copy link
Author

vnys commented Aug 14, 2014

To override the default browser

gulp.task('open', function() {
    gulp.src(path.join(root, 'index.html'))
        .pipe(open('', { app: 'Google Chrome', url: 'http://localhost:'+ port }));
})

@vnys
Copy link
Author

vnys commented Aug 14, 2014

In ze terminal

echo '{}' > package.json
npm i -D gulp gulp-connect gulp-open

@vnys
Copy link
Author

vnys commented Aug 20, 2014

To deploy to gh-pages

var deploy = require('gulp-gh-pages');

gulp.task('deploy', function() {
    gulp.src('./app/**/*').pipe(deploy());
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment