Created
January 31, 2014 19:44
-
-
Save aslansky/8741515 to your computer and use it in GitHub Desktop.
gulp livereload (gulp 3.5.0)
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'); | |
var gutil = require('gulp-util'); | |
var sass = require('gulp-sass'); | |
var lr = require('tiny-lr'); | |
var http = require('http'); | |
var path = require('path'); | |
var ecstatic = require('ecstatic'); | |
var tlr = lr(); | |
var livereload = function (evt, filepath) { | |
tlr.changed({ | |
body: { | |
files: path.relative(__dirname, filepath) | |
} | |
}); | |
}; | |
gulp.task('styles', function () { | |
return gulp.src('./src/scss/main.scss') | |
.pipe(sass()) | |
.pipe(gulp.dest('./dist/css')); | |
}); | |
gulp.task('default', function() { | |
http.createServer(ecstatic({root: __dirname})).listen(8080); | |
gutil.log(gutil.colors.blue('HTTP server listening on port 8080')); | |
tlr.listen(35729); | |
gutil.log(gutil.colors.blue('Livereload server listening on port 35729')); | |
gulp.watch('src/scss/**', ['styles'])._watcher.on('all', livereload); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment