DEV Community

Dima Kuzmich
Dima Kuzmich

Posted on • Originally published at Medium on

Prevent Gulp from stopping watching of files after exception

Recently I developed 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 into a console, I noticed the exception after which 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 un-pipes streams on an error by default.

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


Top comments (0)