Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Rails 3.1 Asset Pipeline

Rails 3.1 Asset Pipeline

A talk on Rails 3.1 (pre-release, talk given before rails 3.1 was released) on how the new asset pipeline will work.

Jeremy Olliver

July 27, 2011
Tweet

More Decks by Jeremy Olliver

Other Decks in Programming

Transcript

  1. Native Support for • Sass • Coffeescript • asset packaging/minification/compression

    • cache friendly static filenames (hash in filename not mtime querystring)
  2. Assets Directory Structure app assets javascripts stylesheets images optional: lib/assets

    (non-application specific assets) vendor/assets (third party assets, css/js plugins etc)
  3. How Does it Work? • manifest files specify js/css files

    to load • app/assets/javascripts/application.js • app/assets/stylesheets/application.css • Only needs changing for specifying load order • Picks up coffeescript, javascript, css, and sass files
  4. Coffeescript / JS compilation • provided through sprockets and execjs

    • Need to include a javascript runtime such as node.js or a native ruby implementation such as gems ‘therubyracer’ or ‘mustang’
  5. Sass / Compass / Referencing assets • use compass ‘rails31’

    branch • use sass (scss) it’s awesome • referencing assets/images requires erb and asset_path helper
  6. Deployment • updated capistrano version coming up • in the

    meantime: • rake assets:precompile RAILS_ENV=production • compiles to public/assets