Skip to content

Instantly share code, notes, and snippets.

@michaelgmcd
Created August 19, 2015 17:32
Show Gist options
  • Save michaelgmcd/3ab69d8ec1f26d5613e6 to your computer and use it in GitHub Desktop.
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.
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