Skip to content
This repository has been archived by the owner on Sep 13, 2018. It is now read-only.
/ voila Public archive

best asset manager one can get in nodejs

Notifications You must be signed in to change notification settings

sunkarapk/voila

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

voila

best asset manager one can get in nodejs (at least we hope so)

Why does voila exist?

We needed an asset manager which meets the following condition:

  • Optimized for runtime such that major processing occurs before deployment, not during app launch.
  • Support CDNs wth the node.js server as origin for assets with md5 extended asset names.
  • Process all major engines like coffee, stylus, less, ejs etc..
  • Provide a helper for asset path which doesn't suck

Under the hood we use mincer which did the heavy lifting.

Voila is the brainchild of Pavan Kumar Sunkara

Installation

Go to you app root directory and run

npm install --save voila

Usage

In your connect/express application

var express = require('express')
  , voila = require('voila')
  , app = expres();

var conf = {
  development: {},
  production: {
    serve: "http://assets.yoursite.com/assets"
  }
}

app.use('/assets', voila(__dirname + '/../', conf[process.env.NODE_ENV])

That pretty much sets up the pipeline. Defaul directory structure is as follows

app
├─┬ assets
│ ├── css
│ ├── js
│ └── img
└─┬ public
  └── assets
  • app/assets should be ignored in .npmignore (which is generally used for nodejs deployment)
  • app/public/assets should be ignored in .gitignore (which is used for committing to repo)

In your package json add the following:

"scripts": {
  "assets": "rm -rf public/assets/* && voila -p http://assets.yoursite.com/assets"
}

This script should be activated before you publish to production, npm run-script assets. It creates the preprocessed files in /public/assets

License

MIT/X11

Bug Reports

Report here.

About

best asset manager one can get in nodejs

Resources

Stars

Watchers

Forks

Packages

No packages published