All the examples I have seen using browserify and gulp assume that you only want to browserify 1 file. This is usually not the case.
I came across an example that used vinyl-transforms, but I am unable to get it to work correctly. Here is the (coffee-script) code:
# Browserify JS
gulp.task 'browserify', [], ->
# Create the transform
br = transform (f) ->
return browserify(f).bundle()
# Run browserify
gulp.src(['./public/js/**/*.js'])
.pipe(br)
.pipe(gulp.dest('.'))
But I get the following error:
[10:50:55] Starting 'browserify'...
events.js:72
throw er; // Unhandled 'error' event
^
Error: write after end
The easiest way would be to use glob
directly:
var glob = require('glob');
gulp.task('browserify', function() {
var files = glob.sync('./public/js/**/*.js');
return browserify({entries: files})
.bundle()
.pipe(gulp.dest('.'));
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With