Skip to content

Instantly share code, notes, and snippets.

@mtomcal
Last active February 18, 2016 01:24
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mtomcal/e2ea440852e90e6d0cc5 to your computer and use it in GitHub Desktop.
Save mtomcal/e2ea440852e90e6d0cc5 to your computer and use it in GitHub Desktop.
Great React + Browserify Gulpfile
var gulp = require('gulp');
var browserify = require('browserify');
var watchify = require('watchify');
var streamify = require('gulp-streamify');
var cssMin = require('gulp-css');
var uglify = require('gulp-uglify');
var notify = require('gulp-notify');
var to5ify = require('6to5ify');
var source = require('vinyl-source-stream');
var webserver = require('gulp-webserver');
gulp.task('cssMinfy', function(){
gulp.src('statics/css/*.css')
.pipe(cssMin())
.pipe(gulp.dest('dist'));
});
gulp.task('browserify', function () {
watchify(browserify('src/app.jsx'))
.transform(to5ify)
.bundle()
.on('error', function(err) {
console.error(err.message);
})
.pipe(source('bundle.js'))
.pipe(streamify(uglify('./dist/')))
.pipe(gulp.dest('./dist/'))
.pipe(notify("Built Bundle"));
});
gulp.task('default', ['browserify']);
gulp.task('watch', function () {
gulp.src('./')
.pipe(webserver({
livereload: true,
}));
gulp.start('default');
gulp.watch('src/*.jsx', ['default']);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment