Stream and transform your browser assets
The goal is to make you able to build your own high performance asset pipeline from small atomic parts, ie. JavaScript bundling. The codebase is still very experimental, so expect big changes ahead.
Example:
var AssetStream = require('assetstream');
var contentSize = AssetStream.helper.contentSize;
var mime = require('mime');
mime.define({
'text/x-handlebars-template': ['hbs']
});
var debugOutput = AssetStream.Destination.create(function() {
return function(asset, next) {
console.log('%s %s (%s B)', asset.event, asset.path, contentSize(asset));
next();
};
});
AssetStream.source.directory({
directory: __dirname,
exclude: '**/*.bundle.js'
}).pipe(
AssetStream.transform.precompileHandlebars()
).pipe(
AssetStream.transform.minifyJavaScript()
).pipe(
AssetStream.transform.bundleJavaScript({ entryPath: '/my-app' })
).pipe(
AssetStream.transform.compressText()
).pipe(
debugOutput()
);
Look around the codebase, if you're curious.
Install: npm install assetstream