Skip to content

Instantly share code, notes, and snippets.

@andyperlitch
Created March 19, 2013 20:23
Show Gist options
  • Save andyperlitch/5199751 to your computer and use it in GitHub Desktop.
Save andyperlitch/5199751 to your computer and use it in GitHub Desktop.
hbs precompile transform
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