Smart asset packaging for Rails, Sinatra, and Stasis.
AssetPackager, but with the following changes:
- Uses file size and hashing to determine if a new compressed package should be created
- YUI Compressor for css compression
- Framework agnostic (adapters provided for Rails 2, Rails 3, Sinatra, and Stasis)
gem install smart_asset
require 'sinatra/base' require 'smart_asset' class Application < Sinatra::Base include :::: end
Create Configuration File
By default, SmartAsset will look for assets in
Create Packaged Assets
cd to your project and run
If your project is Git version controlled, only the assets that have changed are repackaged.
Otherwise, all packages generate every time.
Include Packages in Your Template
Migrating from AssetPackager
- Install SmartAsset
- Instead of running
rake asset:packager:build_all, run
You may add extra options to your
Below are the default values (excluding
You may use environment variables with the
smart\_asset command to alter its behavior.
Output commands that are running, leave the tmp file around for inspection
Only compress a specific package
Use a default modified time other than Time.now for non-version controlled files
Get compression warnings
Forks and contributions to this project are much appreciated, but please make sure the specs run!
To run the basic specs:
There are also framework specs to make sure the helpers work in Rails 2, Rails 3, and Sinatra 1: