Skip to content

Instantly share code, notes, and snippets.

Last active May 28, 2017
What would you like to do?
Using Babel and Browserify with gulp
var gulp = require('gulp');
var browserify = require('browserify');
var through2 = require('through2');
gulp.task('build', function () {
return gulp.src('./src/main.js')
.pipe(through2.obj(function (file, enc, next) {
browserify(file.path, { debug: process.env.NODE_ENV === 'development' })
.bundle(function (err, res) {
if (err) { return next(err); }
file.contents = res;
next(null, file);
.on('error', function (error) {
Copy link

cozuya commented Feb 28, 2015

Thanks, works fine, forgot to require through2 though. Also should mention you can easily get sourcemaps by adding an options argument to line 7 e.g. :

browersify(file.path, {debug: true})

Copy link

Problematic commented Mar 1, 2015

Thanks! I made an edit to enable debug mode when NODE_ENV is "development", but as you say, it's easy enough to get them all the time by setting the debug flag to true.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment