express-asset-handler0.0.3 • Public • Published
Express Asset Handler
npm install --save express-asset-handler
This is express middleware that can handle your script and style includes for both your dev and production work flows. It provides direct links to unoptimized files in dev mode, and cache busted links to optimized files in optimize (production) mode.
Works only with plain js and css files.
To use require the npm and call with the options object.
// Example usagevar assetHandlerMiddleware =assetsJson : // the json object that describes your assetsbaseAssetsDir : pathoptimize : configsoptimize // true or falseoptimizedAssetsDir : path // optimized output directorytmpDir : path;expressApp;// No you can define assets.json that was passed in above:// links are as you wish them to appear in the unoptimized version"css" :"main" :"/css/style1.css""/css/style2.css""js" :"app" :"/js/theme1.js""/js/theme2.js"// And now in any express template you can use!= assets!= assets
options.optimize is false, the above will put two script and style tags each in the html. Each tag will point to the
file referenced in the json.
options.optimize is true, the above will put one script and style tag each in the html. The tags will point to the
created min, concated files, and the file name will include the hash of the contents.
More docs, etc. coming later.