Created
July 8, 2015 10:31
-
-
Save elioair/e308fa8a3cbfb162bb80 to your computer and use it in GitHub Desktop.
Auto-reload browser from gulp server on file edit.
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
var gulp = require('gulp'), | |
livereload = require('gulp-livereload'), | |
less = require('gulp-less'), | |
connect = require('gulp-connect'), | |
minifyCSS = require('gulp-minify-css'); | |
gulp.task('connect', function() { | |
connect.server({ | |
root: 'files', | |
livereload: true, | |
port: 9999 | |
}); | |
}); | |
gulp.task('html', function() { | |
gulp.src('files/*.html') | |
.pipe(livereload()); | |
}); | |
gulp.task('less', function() { | |
gulp.src('files/global/build.less') | |
.pipe(less()) | |
.pipe(minifyCSS()) | |
.pipe(gulp.dest('files/css')) | |
.pipe(livereload()); | |
}); | |
gulp.task('watch', function() { | |
livereload.listen(); | |
gulp.watch(['files/*.html', 'files/**/*.less'], ['less', 'html']); | |
livereload.reload(); | |
}); | |
gulp.task('default', ['connect', 'less', 'html', 'watch']); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment