Last active
August 12, 2016 11:09
-
-
Save hckhanh/8601650fece0be8b7478bd513a831165 to your computer and use it in GitHub Desktop.
A file of gulp tasks for React
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
const gulp = require('gulp'); | |
const browserify = require('browserify'); | |
const babelify = require('babelify'); | |
const source = require('vinyl-source-stream'); | |
const uglify = require('gulp-uglify'); | |
const streamify = require('gulp-streamify'); | |
gulp.task('build:debug', () => { | |
return browserify({ entries: 'js/app.js', debug: true }) | |
.transform('babelify', { presets: ['es2015', 'react'] }) | |
.bundle() | |
.pipe(source('bundle.js')) | |
.pipe(gulp.dest('dist')); | |
}); | |
gulp.task('build', () => { | |
process.env.NODE_ENV = 'production'; | |
return browserify({ entries: 'js/app.js', debug: false }) | |
.transform('babelify', { presets: ['es2015', 'react'] }) | |
.bundle() | |
.pipe(source('bundle.min.js')) | |
.pipe(streamify(uglify())) | |
.pipe(gulp.dest('dist')); | |
}); | |
gulp.task('watch', ['build:debug'], () => { | |
gulp.watch('js/**', ['build:debug']); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment