Last active
August 29, 2015 14:14
-
-
Save nbqx/912c922aeb473c2f78e8 to your computer and use it in GitHub Desktop.
for browserify (reactify)
This file contains 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 browserify = require('browserify'), | |
gulp = require('gulp'), | |
source = require('vinyl-source-stream'), | |
brfs = require('brfs'), // -> if use | |
babelify = require('babelify'), // -> for es6, react | |
uglify = require('gulp-uglify'); | |
var liveServer = require('live-server'); | |
gulp.task('browserify', function() { | |
// neither es6 nor react | |
var b = browserify({ | |
insertGlobals: true, | |
entries: ['/PATH/TO/ENTRYPOINT.js'], | |
transform: [brfs] // if use | |
}); | |
// es6 or react | |
var b = browserify({ | |
entries: ['/PATH/TO/ENTRYPOINT.jsx'], | |
transform: [babelify], | |
debug: false, | |
extensions: ['.jsx'] | |
}); | |
return b.bundle().pipe(source('OUTPUT.js')).pipe(gulp.dest('/PATH/TO/OUTPUT')); | |
}); | |
gulp.task('watch',function(){ | |
return gulp.watch('/PATH/TO/SRC/**/*.js',['browserify']); | |
}); | |
gulp.task('build',['browserify'],function(){ | |
return gulp.src('/PATH/TO/OUTPUT.js') | |
.pipe(uglify()) | |
.pipe(gulp.dest('/PATH/TO/UGLIFIED')); | |
}); | |
gulp.task('server',['browserify'],function(){ | |
return liveServer.start({ | |
port: 8080, | |
root: "/PATH/TO/PUBLIC" | |
}); | |
}); | |
// gulp.task('default',['browserify']); | |
gulp.task('default',['server','watch']); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment