Prevent Gulp from stopping watching of files after exception

Dima Kuzmich
1 min readFeb 26, 2015

--

Recently I did some small project and decided to try and build automated workflow with Gulp. It was very fun and easy. I really liked its features and node-like syntax.

My project included React.js and I used their JSX technology. I wanted to debug my code, thus I needed to compile JSX into vanilla JavaScript. Here is where Gulp came to my rescue. You can easily install gulp-react and it does the magic.

After building my tasks and integrating a compiling I wanted to run my tasks constantly. That’s not a problem when you use Gulp. Just use gulp.watch() and there you are. But after I’ve started to change code, I’ve understood, that my compiled file isn’t updating. When I took a look on a console, I noticed the exception and after it my watching task stopped:

exception

The fix for this problem was another gulp package that called gulp-plumber. This plugin prevents pipe breaking caused by exceptions. Generally saying, it overrides pipe method of gulp and removes onerror handler which unpipes streams on error by default.

To sum it up, it was really good experience using Gulp and its plugins.

--

--