Created
March 19, 2013 20:23
-
-
Save andyperlitch/5199751 to your computer and use it in GitHub Desktop.
hbs precompile transform
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 Stream = require('stream'); | |
| // ---------------------------------- | |
| // Compile handlebars templates | |
| // ---------------------------------- | |
| function createHBTplStream(file) { | |
| var s = new Stream; | |
| s.writable = true; | |
| s.readable = true; | |
| s.write = function(data){ | |
| // If this is a handlebars template, | |
| // compile it here. | |
| s.emit("data",data); | |
| }; | |
| s.end = function(data) { | |
| if (data) s.write(data); | |
| } | |
| s.destroy = function () { | |
| s.writable = false; | |
| }; | |
| return s; | |
| } | |
| var bundle = browserify('./app/start.js') | |
| .transform(createHBTplStream) | |
| .bundle({ | |
| debug: true | |
| }); | |
| bundle.pipe(process.stdout); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment