Wednesday 7 September 2016

Gulp Debugging

I recently ran into a problem where Gulp wouldn't give me the line where a parse error had occurred.
The problem was in the uglify dependency.
To solve it, after much googling, I did the following:

Add this to the beginning of the gulpfile.js:

process.on('uncaughtException', function(error) {
    console.log(error);
    process.exit(1)
});


...and then in the guilty task, make sure the uglify function is called first(so that you don't lose line numbers or other data with minify):

var jsTasks = function(filename) {
return lazypipe()
                .pipe(uglify, { // THIS HAS BEEN MOVED UP compress: { 'drop_debugger': enabled.stripJSDebug } }) .pipe(function() {
return gulpif(enabled.maps, sourcemaps.init());
})
.pipe(concat, filename)
.pipe(function() {
return gulpif(enabled.rev, rev());
})
.pipe(function() {
return gulpif(enabled.maps, sourcemaps.write('.', {
sourceRoot: 'assets/scripts/'
}));
})();
};


No comments:

Post a Comment

Devlog 8: AI and Radar explanation.