Rails 3.0 - 在生产中关闭 Compass/SASS - 样式表 404

发布于 2024-12-02 21:55:44 字数 311 浏览 2 评论 0原文

我在 Heroku 上的 Compass on Rails 3.0 上运行,它运行得很好,但我偶尔会遇到一个问题,即(某些?)样式表的编译速度不如页面的其余部分,因此无法提供它们(. css 链接会导致 404,然后页面将显示为无样式)。

你们知道有一种方法可以让 Compass 在服务器启动时(在产品中)编译所有样式表,然后不再碰它们吗?这样它基本上就会预编译所有必要的样式表并且不会有问题?

或者,在 Heroku 部署之前调用一些脚本将所有样式表编译为 public/stylesheets,然后在生产中完全关闭 Compass 是否更有意义?

谢谢!

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!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

冰之心 2024-12-09 21:55:44

基于此处的讨论:

在 Heroku 上使用 Compass:/ tmp 用于远程和本地样式表

我决定宁愿完全关闭服务器上的样式表编译,正如您建议的替代方法。

我的应用程序的 config.ru 中有以下内容,旨在实现这一目标。

if (ENV['RACK_ENV'] || 'development') != 'development'
    require 'sass/plugin/rack'
    use 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

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文