gpt4 book ai didi

ruby-on-rails - SASS 文件中未使用 Rails CDN URL

转载 作者:太空宇宙 更新时间:2023-11-03 18:25:17 24 4
gpt4 key购买 nike

我如何确保 sass-rails gem 中的 SASS 助手生成针对我的 CDN 的 URL?

我的 application.rb 中有这个:

config.asset_host = 'https://cdn.host.com/'

这使得文档的头部有:

<link href="https://cdn.host.com/favicon.ico" rel="shortcut icon" type="image/vnd.microsoft.icon" />
<link href="https://cdn.host.com/assets/application.css" rel="stylesheet" type="text/css" />

但是我的 CSS 文件看起来像这样:

.splash { background: url('/assets/hero.png'); }

最佳答案

您是否在 SCSS 文件中使用了 image_url 辅助方法?

.splash { background: image_url('assets/hero.png'); }

This article可能会对你有所帮助,顺便说一句,如果你使用的是 SASS(而不是 SCSS),那么你可能需要使用 image-url 而不是 image_url,不过我不确定

更新:

.splash { background: image_url('/assets/hero.png'); }  // will still fetch from the localhost...
.splash { background: image_url('assets/hero.png'); } // work perfectly fine..

关于ruby-on-rails - SASS 文件中未使用 Rails CDN URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12151614/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com