【问题标题】:Font Awesome working locally, but not on HerokuFont Awesome 在本地工作,但不在 Heroku 上
【发布时间】:2014-01-31 04:33:54
【问题描述】:

所以我安装了 font-awesome gem,一切看起来都不错,使用最新版本等。 也包含在我的 application.css 中:

*= require font awesome

当我从本地查看时,结果很好,并且出现了字形图标。当我将它上传到heroku时,图标不显示。我最初显示了方块方块,但我设法修复它,因为我的样式表中有一些杂乱的代码。

我做错了什么或者我错过了什么?

【问题讨论】:

  • 很抱歉,如果这看起来很愚蠢,但是您是否确保在项目的 Gemfile 中将 font-awesome gem 列为要求?听起来 Heroku 由于某种原因找不到 gem,我能想到的最明显的原因是 Gemfile 中缺少它
  • @Moritz 我确保该 gem 已列出。预编译和部署前的一切。我认为这与资产管道有关,但我无法弄清楚我哪里出了问题,因为一切“看起来”都很好。今天要深入一点
  • 你有想过这个吗?

标签: heroku font-awesome


【解决方案1】:

遇到同样的问题并使用以下两个来源的信息解决了它(在 Rails 4 中):Rails Asset Pipeline 和 Rails Asset Pipeline for Heroku

“使用资产管道,这些资产的首选位置现在是 app/assets 目录”。将 font-awesome 的 fonts 文件夹移动到 app/assets,将 font awesome js 和 css 文件移动到 vendor/assets 或 app/assets 适当的 javascripts 和样式表文件夹中。

现在你需要为生产编译资产,运行:

$ rake assets:precompile
$ RAILS_ENV=production bundle exec rake assets:precompile
$ git add public/assets
$ git commit -m "vendor compiled assets"

然后推送到heroku

$ git push heroku master

希望这可以帮助其他偶然发现这个问题的人。

【讨论】:

    猜你喜欢
    • 2016-01-10
    • 2015-04-19
    • 2021-05-23
    • 1970-01-01
    • 2019-11-14
    • 2014-01-02
    • 1970-01-01
    • 1970-01-01
    • 2021-04-26
    相关资源
    最近更新 更多