function buildScript(file, dest) {
    var bundler = browserify({
            entries: [file],
            cache: {},
            packageCache: {}
        }, watchify.args),
        srcFile = file.substring(file.lastIndexOf('/')+1);

    if ( environment !== 'production' ) {
        bundler = watchify(bundler);
        bundler.on('update', function() {
            rebundle();
        });
    }

    function rebundle() {
        gutil.log('Running rebundle');
        return bundler.bundle()
            .on('error', gutil.log.bind(gutil, 'Browserify Error'))
            .pipe( source(srcFile) )
            .pipe( buffer() )
            .pipe( productionOnly(uglify) )
            .pipe( gulp.dest(dest) )
            .pipe( developmentOnly( browserSync.reload, {stream:true} ) );
    }

    return rebundle();
}
function buildScript(file, dest) {
    var bundler = browserify({
            entries: [file],
            cache: {},
            packageCache: {}
        }, watchify.args),
        srcFile = file.substring(file.lastIndexOf('/')+1);

    if ( environment !== 'production' ) {
        bundler = watchify(bundler);
        bundler.on('update', function() {
            rebundle();
        });
    }

    function rebundle() {
        gutil.log('Running rebundle');
        return bundler.bundle()
            .on('error', gutil.log.bind(gutil, 'Browserify Error'))
            .pipe( source(srcFile) )
            .pipe( buffer() )
            .pipe( productionOnly(uglify) )
            .pipe( gulp.dest(dest) )
            .pipe( developmentOnly( browserSync.reload, {stream:true} ) );
    }

    return rebundle();
}
function buildScript ( file , dest ) { var bundler = browserify ( { entries : [ file ] , cache : { } , packageCache : { } } , watchify . args ) , srcFile = file . substring ( file . lastIndexOf ( '/' ) + 1 ) ; if ( environment !== 'production' ) { bundler = watchify ( bundler ) ; bundler . on ( 'update' , function ( ) { rebundle ( ) ; } ) ; } function rebundle ( ) { gutil . log ( 'Running rebundle' ) ; return bundler . bundle ( ) . on ( 'error' , gutil . log . bind ( gutil , 'Browserify Error' ) ) . pipe ( source ( srcFile ) ) . pipe ( buffer ( ) ) . pipe ( productionOnly ( uglify ) ) . pipe ( gulp . dest ( dest ) ) . pipe ( developmentOnly ( browserSync . reload , { stream : true } ) ) ; } return rebundle ( ) ; }
Based on: http://blog.avisi.nl/2014/04/25/how-to-keep-a-fast-build-with-browserify-and-reactjs/
Based on : http : // blog . avisi . nl / 2014 / 04 / 25 / how - to - keep - a - fast - build - with - browserify - and - reactjs /