Skip to content

Instantly share code, notes, and snippets.

@revolunet
Created May 28, 2015 20:31
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 revolunet/14c5aad3c3f013807a63 to your computer and use it in GitHub Desktop.
Save revolunet/14c5aad3c3f013807a63 to your computer and use it in GitHub Desktop.
browserify + babel
var fs = require("fs");
var browserify = require("browserify"),
babelify = require("babelify"),
watchify = require('watchify'),
partialify = require('partialify');
var input = './www/js/commonjs/app.js',
output = './www/bundle.js',
debug = true;
// define transformations
var b = browserify(input, {
debug: debug,
verbose: true,
extensions: ['.js', '.es6', '.jsx']
})
.transform(babelify.configure({
extensions: ['.js', '.es6', '.jsx'],
stage: 0
}))
// html templates and more
.transform(partialify)
.on("error", function (err) {
console.log("Error : " + err.message);
});
// watch sources
var w = watchify(b, {
verbose: true,
debug: debug,
poll: true
})
.on("log", function (msg) { console.log(msg); })
.on("update", function(ids) {
console.log('update bundle: ' + ids.length + ' files');
})
.bundle()
.pipe(fs.createWriteStream(output));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment