-
-
Save codewisdom/4c02ce8084f40555651fbf1c8aefacb6 to your computer and use it in GitHub Desktop.
Show sass compilation errors in the browser
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 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