Logging detailed error messages when running Gulp.js tasks

gulp
Gulp.js has become one of the most used task managers nowadays. But sometimes, when running several tasks with many pipes( ) on them, it is very difficult to understand what’s wrong or the actual reason why our task is not working as expected. For others like me, who like to have a better error description, here is what needed to do:
Install Gulp Util
npm install —save-dev gulp-util
Import the Gulp Util by using the following statement:
var gutil = require('gulp-util');
Finally, in your pipes, add a new “event” to manage the “error”, e.g. when you are uglifying your code, here is how you can attach the error handler of gulp util:
.pipe(uglify().on('error', gutil.log))

Notice the “on(‘error’)” part, that is where the magic happens.

Hope you find this top useful, see you next time!

Leave a Reply

Your email address will not be published. Required fields are marked *