I have the following function for bundling my JavaScript modules:
function buildScript( entryPoint, doDebug ) {
return browserify( {
entries: [ './dev-res/js/' + entryPoint ],
extensions: [ '.js' ],
debug: doDebug ? true : false
} )
.transform( babelify, {
presets: [ "es2015", "react", "stage-0" ] } )
.bundle()
.on( 'error', handleErrors )
.pipe( source( entryPoint ) )
.pipe( buffer() )
.pipe( uglify() )
.pipe( gulp.dest( './res/js/' ) );
}
I want to trigger these two lines
.pipe( buffer() )
.pipe( uglify() )
only when doDebug
is not true
. This means I should declare a variable to remove the chained calls. I tried saying
var module = browserify( {
entries: [ './dev-res/js/' + entryPoint ],
extensions: [ '.js' ],
debug: doDebug ? true : false
} );
But then I get something like browserify has no method pipe
, so this is my problem: I don't know what to save in that variable. I admit that I don't really have a deep understanding of how browserify
define their code and how it actually works, but I just need to get this method do what I want.