Last active
September 15, 2015 09:49
-
-
Save wtfil/e346e1d34489b95e5dba to your computer and use it in GitHub Desktop.
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 browserify = require('browserify'); | |
var watchify = require('watchify'); | |
var gutil = require('gulp-util'); | |
var fs = require('fs') | |
var files = { | |
js: { | |
src: 'path to src', | |
dst: 'path to dst' | |
} | |
}; | |
gulp.task('js-watch', function () { | |
var args = watchify.args; | |
args.degub = true; | |
var bundler = watchify(browserify(files.js.src, args)); | |
bundler.transform('babelify'); | |
bundler.on('update', rebundle); | |
function onError(e) { | |
gutil.log(gutil.colors.red(e.message)); | |
} | |
function rebundle() { | |
var start = Date.now(); | |
return bundler.bundle() | |
.on('error', onError) | |
.on('end', function () { | |
var time = Date.now() - start; | |
gutil.log('Building \'' + gutil.colors.green(files.js.src) + '\' in ' + gutil.colors.magenta(time + ' ms')); | |
}) | |
.pipe(fs.createWriteStream(files.js.dest)); | |
} | |
rebundle(); | |
}); |
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
{ | |
"dependencies": { | |
"babelify": "^6.1.2", | |
"browserify": "^10.2.4", | |
"gulp": "^3.9.0", | |
"gulp-util": "^3.0.6", | |
"react": "^0.13.3", | |
"watchify": "^3.2.3", | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment