Improve gulp on error

I’m using sass with ionic, but whenever I get an error with the sass compiler, it breaks everything, making me have to restart ionic serve

So I just added this into the gulp file, and now it gives a neat error and aborting, instead of breaking everything

var errorAlert;
gulp.task("sass", function(done) {
  gulp.src("./scss/ionic.app.scss")
    .pipe(sass())
    .on("error", errorAlert)
    .pipe(gulp.dest("./www/css/"))
    .pipe(minifyCss({
      keepSpecialComments: 0
    }))
    .pipe(rename({ extname: ".min.css" }))
    .pipe(gulp.dest("./www/css/"))
    .on("end", done);
});

errorAlert = function(err) {
  console.log(err.toString());
  this.emit("end");
};

Wouldn’t this do the same thing (but a bit simpler):

.pipe(sass({
  errLogToConsole: true
}))

That’s what’s in the gulpfile when you start, but it breaks whenever there’s an error

Okay I see, thanks, I’ll add your technique to my gulp file.

I actually asked this question a bit back because I was having the same issue. The blog post they wrote about it might help you too

http://blog.ionic.io/fixing-a-broken-sass-build-stream/