Question

I am running on Compass on Rails 3.0 on Heroku and its pretty much working fine, but I occasionally have an issue where (some?) stylesheets aren't compiled as fast as the rest of the page so they aren't served (the .css links cause 404's and the page is then displayed unstyled).

Do you guys know of a way to make Compass compile all stylesheets on server start up (in prod) and then not touch them again? That way it'll basically precompile all the necessary stylesheets and there won't be an issue?

Or alternately, would it make more sense to call some script before heroku deploy that compiled all the stylesheets to public/stylesheets, and then turn off Compass in production altogether?

Thanks!

Was it helpful?

Solution

Based on the discussion here:

Using Compass on Heroku: /tmp for stylesheets remotely and locally

I decided that I would rather turn off stylesheet compilation on the server entirely as you suggest as your alternate approach.

I have the following in my app's config.ru which is intended to achieve just that.

if (ENV['RACK_ENV'] || 'development') != 'development'
    require 'sass/plugin/rack'
    use Sass::Plugin::Rack
    Sass::Plugin.options[:never_update] = true
end

UPDATE: I replaced this approach with the simpler one of adding

Sass::Plugin.options[:never_update] = true

to the very bottom of my production.rb environment file which works a charm on Heroku. As described here:

http://ariejan.net/2010/09/28/precompile-sass-to-css-for-deployment-to-heroku

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top