Skip to content

Instantly share code, notes, and snippets.

@codewisdom
Forked from lmartins/gulpfile.js
Created March 15, 2018 00:43
Show Gist options
  • Save codewisdom/4c02ce8084f40555651fbf1c8aefacb6 to your computer and use it in GitHub Desktop.
Save codewisdom/4c02ce8084f40555651fbf1c8aefacb6 to your computer and use it in GitHub Desktop.
Show sass compilation errors in the browser
var gulp = require("gulp");
var sass = require("gulp-sass");
var autoprefix = require("gulp-autoprefixer");
var filter = require('gulp-filter');
var browserSync = require('browser-sync');
var reload = browserSync.reload;
/**
* Start BrowserSync
*/
gulp.task('browser-sync', function () {
browserSync({
server: "./dist"
});
});
/**
* Compile sass
*/
gulp.task('sass', function () {
return gulp.src('lib/scss/**/*.scss')
.pipe(sass())
.on('error', function(err){
browserSync.notify(err.message, 3000);
this.emit('end');
})
.pipe(autoprefix())
.pipe(gulp.dest('lib/css'))
.pipe(filter("**/*.css"))
.pipe(reload({stream:true}));
});
/**
* Watch
*/
gulp.task('default', ['sass', 'browser-sync'], function () {
gulp.watch('lib/scss/**/*.scss', ['sass']);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment