Pound
Pound 2.0 - High-level asset management for NodeJS/Express like it should be.
Pound allows you to think of assets in terms of packages/bundles.
Pound supports Express 2 and 3 and use Bundle-Up as the underlying asset manager.
Npm
npm install pound
Basic usage
example/server_simple.js
var express = Pound = bundle = pounddefineAsset; // alias // Define where is the public directoryvar pound = Pound; // By default all bundle's assets are public (if another inherit from it, it'll get all of those assets); ; var app = express; app; {return {res;};} app;app; app;
example/view/home.jade
!!! 5html head title Pound rocks ! !{renderStyle("home")} body p Look at the source code and then try to start the server with <pre>NODE_ENV=production node server.js</pre> a(href="/app") Go the app page (with app assets) !{renderScript("home")}
example/view/app.jade
!!! 5html head title Pound rocks ! !{renderStyle("app")} body p Look at the source code and then try to start the server with <pre>NODE_ENV=production node server.js</pre> a(href="/") Go the homepage (with the home assets) !{renderScript("app")}
Recommended usage
example/server.js
var express = assets = app = express; app; {return {res;};} app;app; app;
example/assets.js
/*** Specify the assets*/ var pound = bundle = pounddefineAsset; // Default parameters are:// pound.public = __dirname + '/public';// pound.resolve.css = function(filename){return this.publicDir + '/css/'+filename+'.css';};// pound.resolve.js = function(filename){return this.publicDir + '/js/'+filename+'.js';}; // Override default resolve function for `$js` and `$css`poundresolve{return __dirname + '/assets/js/'+filename+'.js';};poundresolve{return __dirname + '/assets/css/'+filename+'.css';}; // Add new resolve function for `$myCssDir` and `$appjs`// The resolve function's result will replace `$resolveFunctionName` for each resourcespoundresolve{return __dirname + '/assets/css/'+filename+'.css';};poundresolve{return __dirname + '/app/'+filename+'.js';}; ; ; moduleexports = pound;
views/app.jade
and view/home.jade
are the same as mentionned in the simple usage
Oh wait... and it supports OO-style inheritance
; ;
One more thing... Asset precompilation
//// add some assets via pound.defineAsset// pound
Donate
License
Copyright (c) 2012 Francois-Guillaume Ribreau (npm@fgribreau.com)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.