Created
August 19, 2015 17:32
-
-
Save michaelgmcd/3ab69d8ec1f26d5613e6 to your computer and use it in GitHub Desktop.
A simple gulpfile for hosting static files with browsersync, compiling SASS files, and reloading/injecting the browser when needed.
This file contains 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 gulpSass = require('gulp-sass'); | |
var minifyCss = require('gulp-minify-css'); | |
var sourcemaps = require('gulp-sourcemaps'); | |
var prefix = require('gulp-autoprefixer'); | |
var browserSync = require('browser-sync').create(); | |
gulp.task('scss', function() { | |
return gulp.src('style.scss') | |
.pipe(sourcemaps.init()) | |
.pipe(gulpSass().on('error', gulpSass.logError)) | |
.pipe(prefix()) | |
.pipe(minifyCss()) | |
.pipe(sourcemaps.write()) | |
.pipe(browserSync.stream()); | |
}); | |
// Launch BrowserSync server | |
gulp.task('serve', ['scss'], function(cb) { | |
browserSync.init({ | |
notify: true, | |
server: '.' | |
}); | |
gulp.watch('*.scss', ['scss']); | |
gulp.watch('*.html').on('change', browserSync.reload); | |
}); | |
gulp.task('default', ['serve']); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment