Created
June 18, 2014 13:19
-
-
Save naeramarth7/e55ea54ef8c72667dd7b to your computer and use it in GitHub Desktop.
Basic gulpfile with gulp-livereload and gulp-connect features.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'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