Rails 3.0 - 将生产中的指南针/ SASS关闭 - 样式表404 [英] Rails 3.0 - Turn Compass/SASS off in Production - Stylesheets 404

查看:154
本文介绍了Rails 3.0 - 将生产中的指南针/ SASS关闭 - 样式表404的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Heroku上运行Compass on Rails 3.0并且它的工作正常,但偶尔有一个问题(某些?)样式表没有像页面其余部分一样快速编译,因此它们没有被提供(.css链接会导致404和页面显示为无风格)。



您是否知道使Compass能够编译服务器上所有样式表的方法(在prod),然后不再触摸它们?那么它将基本预编译所有必要的样式表,并且不会有问题?或者,在heroku部署之前调用某些脚本会更有意义吗?将所有样式表编译为public / stylesheets,然后关闭生产中的Compass?

谢谢!

解决方案

基于这里的讨论:





我决定,我宁愿关闭服务器上的样式表编译,因为您建议您作为替代方法。



我在应用程序的config.ru中有以下内容:打算实现这一点。

  if(ENV ['RACK_ENV'] ||'development')!='development'
需要'sass / plugin / r ack'
使用Sass :: Plugin :: Rack
Sass :: Plugin.options [:never_update] = true
end

更新:我用更简单的方法替换了这个方法

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

到我的production.rb的最底部环境文件,在Heroku上运行一个魅力。如此处所述:

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


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!

解决方案

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

这篇关于Rails 3.0 - 将生产中的指南针/ SASS关闭 - 样式表404的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆