Last active
August 29, 2015 14:01
-
-
Save RnbWd/fc6388bf028eb7786660 to your computer and use it in GitHub Desktop.
gulp-browserify-experiments
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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