Rails 3.0 - 在生产中关闭 Compass/SASS - 样式表 404
我在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
基于此处的讨论:
在 Heroku 上使用 Compass:/ tmp 用于远程和本地样式表
我决定宁愿完全关闭服务器上的样式表编译,正如您建议的替代方法。
我的应用程序的 config.ru 中有以下内容,旨在实现这一目标。
更新:我用更简单的方法替换了这种方法,即添加
到我的 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.
UPDATE: I replaced this approach with the simpler one of adding
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