Skip to content

Instantly share code, notes, and snippets.

@nurfaizfoat
Created February 24, 2015 10:02
Show Gist options
  • Save nurfaizfoat/5a35fb017672cc9c0c4e to your computer and use it in GitHub Desktop.
Save nurfaizfoat/5a35fb017672cc9c0c4e to your computer and use it in GitHub Desktop.
var gulp = require('gulp');
var plumber = require('gulp-plumber');
var webserver = require('gulp-webserver');
var opn = require('opn');
var sourcePaths = {
html: ['*.html']
style: ['css/*.css']
images: ['img/**/*.jpg', 'img/*.jpg']
};
var server = {
host: 'localhost',
port: '8001'
}
gulp.task('webserver', function() {
gulp.src( '.' )
.pipe(webserver({
host: server.host,
port: server.port,
livereload: true,
directoryListing: false
}));
});
gulp.task('openbrowser', function() {
opn( 'http://' + server.host + ':' + server.port );
});
gulp.task('watch', function(){
gulp.watch(sourcePaths.html, ['html']);
gulp.watch(sourcePaths.style, ['styles']);
gulp.watch(sourcePaths.images, ['images']);
});
gulp.task('default', ['webserver', 'watch', 'openbrowser']);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment