Best way to combine and minify JS / CSS on Heroku Best way to combine and minify JS / CSS on Heroku ruby-on-rails ruby-on-rails

Best way to combine and minify JS / CSS on Heroku


I'm using Jammit on Heroku. Works Great. You can locally build your assets and check in to heroku. use

jammit --force

the current version 0.5.1 has issues working on heroku but you can install the fixed version from git://github.com/documentcloud/jammit.git

If you are using Rails 3, specify the below in your bundler Gemfile:

gem "jammit", :git => "git://github.com/documentcloud/jammit.git"

For Rails 2.*

config.gem "jammit", :source => "git://github.com/documentcloud/jammit.git"

Good Luck.


I've found that adding a git pre–commit hook which compiles and packs assets, then adds them to the current commit comes in handy in this case.

Mine using Jammit looks something like this (in .git/hooks/pre-commit):

jammitrake barista:brewgit add public/assets/*git add public/javascripts/*

Like this all your assets will be packed for you and you don't have to worry anymore about it.


GitHub has a good answer for this, and I'm sure you could modify Heroku's deployment scripts to integrate:

http://github.com/blog/551-optimizing-asset-bundling-and-serving-with-rails