Created
May 28, 2015 20:31
-
-
Save revolunet/14c5aad3c3f013807a63 to your computer and use it in GitHub Desktop.
browserify + babel
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 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