0.1.0 • Published 12 years ago
power-assets v0.1.0
Power Assets
Power Assets is a assets pipeline for express.
Install
npm install --save power-assetsFeatures
- sets the correct headers for production
- gzip compression
- cache busting name generation
- dev mode where ondisk changes are auto bundled.
Plugins
- Less
- Browserify- debowerify
- reactify
- uglify
 
Configuration
For LESS CSS asset. Options are passed through to LESS compiler.
"cssAssetConf": {
  "url": "/main.css",         // server endpoint
  "entry": "app/stylesheets/main.less", // less entry
  "cleancss": false,          // use cleancss
  "sourceMap": true,
  "outputSourceFiles": true,
  "strictMath": true,
  "strictUnit": true,
  "ieCompat": false,
  "compress": false,        // gzip output
  "watch": true,            // watch for changes
  "hash": false,            // cachebusting url
  "copyright": "/* © 2014 QUILLU INC. */", // preprend copywright
  "maxAge": 0
}For Browserify JS asset. Options are passed through to Browserify.
"jsAssetConf": {
  "url": "/main.js",        // server endpoint
  "entry": "app/client.js", // browserify entry
  "minify": false, // Run bundle through uglify
  "insertGlobals": true,
  "transforms": ["debowerify", "reactify"],
  "debug": true,
  "compress": false,        // gzip output
  "watch": true,            // watch for changes
  "hash": false,            // cachebusting url
  "copyright": "/* © 2014 QUILLU INC. */", //prepend copyright
  "maxAge": 0
}Then create asset rack
var assets = require('power-assets');
// - LESS CSS
var cssAsset = new assets.LessAsset(cssAssetConf);
cssAsset.on('ready', function() {
  console.log('CSS asset complete');
});
if (cssAssetConf.watch) {
  cssAsset.on('error', function(err) {
    console.log(err);
  });
}
// - Browserify Javascript
var jsAsset = new assets.BrowserifyAsset(jsAssetConf);
jsAsset.on('ready', function() {
  console.log('JS asset complete');
});
if (jsAssetConf.watch) {
  jsAsset.on('error', function(err) {
    console.log(err);
  });
}
// Construct a rack with many individual assets
var rack = assets.rack([cssAsset, jsAsset]);
// Add as middleware to Express server
server.use(rack);Developer
Inspired by various asset pipeline systems.
Create Github issues for all bugs, features & requests. Pull requests are welcome.
Test
Test with npm test
License
0.1.0
12 years ago

