Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 13 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kornelski/ca9631f5348383b61bc7b359e96ced38 to your computer and use it in GitHub Desktop.
Save kornelski/ca9631f5348383b61bc7b359e96ced38 to your computer and use it in GitHub Desktop.
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
Copy link

Thanks Bro!

@vladyn
Copy link

vladyn commented Jul 20, 2017

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

@antoc0d3
Copy link

antoc0d3 commented Aug 3, 2017

Thanks bro

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