Web Asset Graph
The most obvious usage (to me) is building highly optimized website deploys by traversing the graph and applying operations (minification, renaming based on hashing, app cache generation, etc.)
This could become part of a grunt workflow, or you could build your own custom tools. It's up to you.
This tool is inspired by assetgraph and assetgraph-builder.
- simple API
- only 500 lines of code
- supports basic RequireJS and Browserify syntax
- provides command line tool and programmatic API
- can rename files based on their MD5 hash
- can prefix assets with a CDN host
cd projectdirwag --inp public/ --out deploy/ --cdnroot mycdn.cloudfront.net --hash --minify
What this does:
- Traverse assets in a
public/directory, writing them out to
- Minifies each file.
- Renames the assets to the md5 of the their contents. (e.g.,
/img/dog.pngis re-rewritten to
- Re-writes the URL for the asset to point at a CDN version (e.g.,
/static/343e32abce3968feac.pngis re-written to
AssetGraph = require'wag'AssetGraphroot = '/Users/mike/wwwroot/mywebsite'ag = root# load all of the asset files directlyagloadAssets 'index.html'agloadAssets 'js/'consolelog "\nloaded assets"agminifyAssetsagmoveAssets 'static/'out = '/Users/mike/Desktop/deployfolder'# rename each file (except for index.html) to an md5 hash of it's contentsuseHashName = trueagwriteAssetsToDisc outuseHashName