Created
October 13, 2015 03:44
-
-
Save kimsk/8043c7345c989e2b3955 to your computer and use it in GitHub Desktop.
gulp for react 0.14, browserify, watchify, babelify, uglify
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
'use strict'; | |
var del = require('del'); | |
var gulp = require('gulp'); | |
var browserify = require('browserify'); | |
var source = require('vinyl-source-stream'); | |
var babelify = require('babelify'); | |
var watchify = require('watchify'); | |
var uglify = require('gulp-uglify'); | |
var buffer = require('vinyl-buffer'); | |
var paths = { | |
src: '.', | |
des: './build' | |
}; | |
gulp.task('clean', function(done) { | |
del([paths.des], done); | |
}); | |
gulp.task('watch-and-bundle', function () { | |
var b = watchify(browserify('./main.js')); | |
var bundle = function(){ | |
console.log('bundle..'); | |
b.transform(babelify) | |
.bundle() | |
.pipe(source('bundle.js')) | |
.pipe(buffer()) | |
.pipe(uglify()) | |
.pipe(gulp.dest(paths.des)); | |
}; | |
b.on('update', bundle); | |
return bundle(); | |
}); | |
// command line: browserify -t babelify main.js -o bundle.js | |
gulp.task('bundle', function () { | |
browserify('./main.js') | |
.transform(babelify) | |
.bundle() | |
.pipe(source('bundle.js')) | |
.pipe(gulp.dest(paths.des)); | |
}); | |
gulp.task('default', ['clean', 'bundle']); |
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
{ | |
"name": "try-react-0.14", | |
"version": "1.0.0", | |
"description": "", | |
"main": "main.js", | |
"scripts": { | |
"test": "echo \"Error: no test specified\" && exit 1" | |
}, | |
"author": "", | |
"license": "ISC", | |
"dependencies": { | |
"babelify": "^6.3.0", | |
"browserify": "^11.2.0", | |
"del": "^2.0.2", | |
"gulp": "^3.9.0", | |
"gulp-uglify": "^1.4.2", | |
"react": "^0.14.0", | |
"react-dom": "^0.14.0", | |
"vinyl-buffer": "^1.0.0", | |
"vinyl-source-stream": "^1.1.0", | |
"watchify": "^3.4.0" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment