gulpfile.js
function bundle(srcFiles, destDir, optionsFn) {
    return gulp.src(srcFiles, {
        read: false
    })
    .pipe(tap(function(file) {
        var options = {};
        if (optionsFn) options = optionsFn(file);
        var fileName = options.fileName || path.basename(file.path);

        if (options.standalone)
            console.log(`Creating ${options.standalone} in ${destDir}/${fileName}`);
        else
            console.log(`Creating ${destDir}/${fileName}`);

        file.contents = browserify(file.path, options)
            .ignore("buffer")
            .ignore("dotenv")
        .bundle()
            .on("error", function (err) {
                console.log(err);
            });
        file.path = path.join(file.base, fileName);
    }))
    .pipe(buffer())
    .pipe(sourcemaps.init({
        loadMaps: true
    }))
    .pipe(uglify({
        preserveComments: function(node, comment) {
            return comment.value.includes("Copyright Arm");
        }
    }))
    .pipe(sourcemaps.write(".", {
        sourceRoot: path.relative(destDir, nodeDir)
    }))
    .pipe(gulp.dest(destDir));
}
function bundle(srcFiles, destDir, optionsFn) {
    return gulp.src(srcFiles, {
        read: false
    })
    .pipe(tap(function(file) {
        var options = {};
        if (optionsFn) options = optionsFn(file);
        var fileName = options.fileName || path.basename(file.path);

        if (options.standalone)
            console.log(`Creating ${options.standalone} in ${destDir}/${fileName}`);
        else
            console.log(`Creating ${destDir}/${fileName}`);

        file.contents = browserify(file.path, options)
            .ignore("buffer")
            .ignore("dotenv")
        .bundle()
            .on("error", function (err) {
                console.log(err);
            });
        file.path = path.join(file.base, fileName);
    }))
    .pipe(buffer())
    .pipe(sourcemaps.init({
        loadMaps: true
    }))
    .pipe(uglify({
        preserveComments: function(node, comment) {
            return comment.value.includes("Copyright Arm");
        }
    }))
    .pipe(sourcemaps.write(".", {
        sourceRoot: path.relative(destDir, nodeDir)
    }))
    .pipe(gulp.dest(destDir));
}
function bundle ( srcFiles , destDir , optionsFn ) { return gulp . src ( srcFiles , { read : false } ) . pipe ( tap ( function ( file ) { var options = { } ; if ( optionsFn ) options = optionsFn ( file ) ; var fileName = options . fileName || path . basename ( file . path ) ; if ( options . standalone ) console . log ( ` ${ options . standalone } ${ destDir } ${ fileName } ` ) ; else console . log ( ` ${ destDir } ${ fileName } ` ) ; file . contents = browserify ( file . path , options ) . ignore ( "buffer" ) . ignore ( "dotenv" ) . bundle ( ) . on ( "error" , function ( err ) { console . log ( err ) ; } ) ; file . path = path . join ( file . base , fileName ) ; } ) ) . pipe ( buffer ( ) ) . pipe ( sourcemaps . init ( { loadMaps : true } ) ) . pipe ( uglify ( { preserveComments : function ( node , comment ) { return comment . value . includes ( "Copyright Arm" ) ; } } ) ) . pipe ( sourcemaps . write ( "." , { sourceRoot : path . relative ( destDir , nodeDir ) } ) ) . pipe ( gulp . dest ( destDir ) ) ; }
Browserify helper function
Browserify helper function