0

I use this browserify task to bundle my javascript:

gulp.task('browserify', function(done) {
    var files = globby.sync(local.jsBundles);
    return merge(files.map(function(file) {
        return browserify({
            entries: file,
            debug: true
        }).transform(babelify, {presets: ["env", "react"]})
            .bundle()
            .on('error', function(e) {
                console.log(gutil.colors.bgBlack('[Error while bundling]'));
                console.log(gutil.colors.gray(e.message));
                this.emit('end');
            })
            .pipe(source(path.basename(file, '.js') + '.js'))
            .pipe(buffer())
            .pipe(uglify())
            .pipe(sourcemaps.write())
            .pipe(gulp.dest(local.jsDist + '/bundles'))
    })).on('end', done);
});

This works very well for me; But it takes about 18 seconds to finish, even though I am only bundling 6 files. I realize that browserify also follows the imports from the react packages. Several solutions I could find suggested working with watchify, but I couldn't get it to work on my task. Could anyone help me with this and tell what I am doing wrong here?

Nachtfunke
  • 329
  • 1
  • 14
  • Possible duplicate of [gulp browserify reactify task is quite slow](https://stackoverflow.com/questions/28162686/gulp-browserify-reactify-task-is-quite-slow) – Yosef Weiner Jul 04 '17 at 11:56
  • I have tried making these solutions work for me, but they don't. All resources I find cannot handle multiple entry points with globs. – Nachtfunke Jul 26 '17 at 09:04

0 Answers0