Skip to content

Instantly share code, notes, and snippets.

@lmartins
Forked from anonymous/gulpfile.js
Last active September 2, 2018 17:08
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save lmartins/cebf7d01992e18888ecf to your computer and use it in GitHub Desktop.
Save lmartins/cebf7d01992e18888ecf 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']);
});
@landsman
Copy link

thanks for sharing this code buddy!

Copy link

ghost commented Sep 2, 2018

thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment