- The new asset pipeline in Rails 3.1 makes assets first class citizens in Rails
- Assets now in app/assets rather than public (also lib/assets, vendor/assets)
- Asset files can inline other asset files using requires
- Asset packages are defined in manifests
/*
*= require blueprint/reset
*= require blueprint/typography
*/
- Gem dependencies can provide asset files for the application to use
- In production mode, generated files include an MD5 hash as part of the file name
- At the heart of the pipeline is Sprockets 2.0
- Sprockets will allow any number of filters to be used with asset files
- run a file through SASS and ERB by naming it stylesheet.css.scss.erb
body {
background: url(<%= asset_path "sunshine-rainbows-and-lollipops.png" %>);
/* You have to use ERB to link to asset pipelined resource */
}
- CoffeeScript and SASS are now included in the default template
- Invoke w/ application.js.coffee, application.css.sass
- support for JS minification comes built-in with Rails via UglifyJS
http://guides.rubyonrails.org/asset_pipeline.html
https://github.com/sstephenson/sprockets
http://blog.nodeta.com/2011/06/14/rails-3-1-asset-pipeline-in-the-real-world/