开发者

Rails 3.0 - Turn Compass/SASS off in Production - Stylesheets 404

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 pu开发者_如何学Goblic/stylesheets, and then turn off Compass in production altogether?

Thanks!


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜