Skip to content

Instantly share code, notes, and snippets.

@melvinlee
Created October 9, 2015 02:24
Show Gist options
  • Select an option

  • Save melvinlee/126cc2474c575ece32c4 to your computer and use it in GitHub Desktop.

Select an option

Save melvinlee/126cc2474c575ece32c4 to your computer and use it in GitHub Desktop.
Gulp configuration using watch, connect and reload.
"use strict";
var gulp = require('gulp');
var connect = require('gulp-connect');
var open = require('gulp-open');
var config = {
port: 8005,
devBaseUr: 'http://localhost',
paths: {
html : './src/*.html',
dist : './dist'
}
}
gulp.task('connect',function(){
connect.server({
root:['dist'],
port: config.port,
base: config.devBaseUrl,
livereload: true
})
});
gulp.task('open',['connect'],function(){
gulp.src('dist/index.html')
.pipe(
open({
uri: config.devBaseUr + ':' + config.port + '/'
}));
});
gulp.task('html', function(){
gulp.src(config.paths.html)
.pipe(gulp.dest(config.paths.dist))
.pipe(connect.reload());
});
gulp.task('watch',function(){
gulp.watch(config.paths.html,['html']);
})
gulp.task('default',['html','open','watch']);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment