Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
gulp.task('css-browsersync', function() {
return gulp.src(["*.scss"])
.pipe(sass().on('error', function(err) {
console.error(err.message);
browserSync.notify(err.message, 3000); // Display error in the browser
this.emit('end'); // Prevent gulp from catching the error and exiting the watch process
}))
.pipe(gulp.dest("public/"))
.pipe(browserSync.stream());
});
gulp.task('watch', ['css-browsersync'], function() {
browserSync.init({
server: "./public"
});
gulp.watch("*.scss", ['css-browsersync']);
gulp.watch("public/*.html").on('change', browserSync.reload);
// protip: stop old version of gulp watch from running when you modify the gulpfile
gulp.watch("gulpfile.js").on("change", () => process.exit(0));
});
@GoodProject

This comment has been minimized.

Copy link

@GoodProject GoodProject commented Apr 30, 2017

Thanks Bro!

@vladyn

This comment has been minimized.

Copy link

@vladyn vladyn commented Jul 20, 2017

Thanks - this with the message to the browserSync is really handy.

@jersonjcnt

This comment has been minimized.

Copy link

@jersonjcnt jersonjcnt commented Aug 3, 2017

Thanks bro

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