Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@RnbWd
Last active August 29, 2015 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RnbWd/fc6388bf028eb7786660 to your computer and use it in GitHub Desktop.
Save RnbWd/fc6388bf028eb7786660 to your computer and use it in GitHub Desktop.
gulp-browserify-experiments
var $ = require('gulp-load-plugins')();
var reactify = require('reactify');
var envify = require('envify');
var browserify = require('browserify');
var watchify = require('watchify');
//watchify with source maps
gulp.task('watchify', function() {
var w = watchify({entries: ['./src/js/init.jsx'],
extensions:['.jsx']});
w.transform(envify)
.transform(reactify)
.on('update', rebundle)
.on('time', function (time) {
$.util.log(time);
});
function rebundle() {
w.bundle({debug: true})
.on('error', $.util.log)
.pipe(source('scripts.js'))
.pipe(gulp.dest('./build'));
}
rebundle();
});
//browserify-transforms work with gulp vinyls
var vtransform = require('vinyl-transform');
gulp.task('transform', function() {
gulp.src('./src/js/init.jsx')
.pipe(vtransform(reactify))
.pipe(vtransform(envify))
.pipe(gulp.dest('./weird'))
});
//what I'm trying to do..
gulp.task('hope', function() {
gulp.src('./src/js/init.jsx')
.pipe($.tap(function(file, t) {
browserify({entries: [file.path],
extensions:['.jsx']
})
.transform(envify)
.transform(reactify)
.bundle({debug: true})
.on('error', $.util.log)
.pipe(source('scripts.js'))
.pipe(gulp.dest('./why'))//I want to take this out of the pipe..
}))
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment