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

六月ゝ 毕业季﹏ 提交于 2019-12-13 04:13:20

问题


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!


回答1:


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



来源:https://stackoverflow.com/questions/7300815/rails-3-0-turn-compass-sass-off-in-production-stylesheets-404

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!