Skip to content

Instantly share code, notes, and snippets.

@naeramarth7
Created June 18, 2014 13:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save naeramarth7/e55ea54ef8c72667dd7b to your computer and use it in GitHub Desktop.
Save naeramarth7/e55ea54ef8c72667dd7b to your computer and use it in GitHub Desktop.
Basic gulpfile with gulp-livereload and gulp-connect features.
'use strict';
/* global require */
// Define dependencies
var gulp = require('gulp'),
connect = require('gulp-connect'),
livereload = require('gulp-livereload');
// Define file locations
var htmlFiles = [ 'app/**/*.html' ],
cssFiles = [ 'app/css/**/*.css' ],
jsFiles = [ 'app/js/**/*.js' ];
// Task for setting up webserver when working without backend
gulp.task('connect', function() {
connect.server({
root: 'app',
livereload: false
});
});
gulp.task('_watch', function() {
// Create LiveReload server
var server = livereload();
livereload.listen();
// Watch any files in dist/ for changes
gulp.watch([].concat( htmlFiles, jsFiles, cssFiles )).on('change', function(file) {
server.changed(file.path);
});
});
// Watcher task when working WITHOUT backend
gulp.task('watch-server', [ 'connect', '_watch' ]);
// Watcher task when working WITH backend
gulp.task('watch', [ '_watch' ]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment