0

hoping for some help. I have a rails project that in production does not seem to be compiling the fonts.

In my application.rb file I have

 class Application < Rails::Application
   config.assets.paths << Rails.root.join("app", "assets", "fonts")
 end

With the fonts being added to my scss file like

@font-face {
   font-family: 'Jaapokki';
   src: asset-url("/assets/Jaapokki-Regular.eot");
   src: asset-url("/assets/Jaapokki-Regular.eot?#iefix") 
   format("embedded-opentype"), asset-url("/assets/Jaapokki-Regular.woff") format("woff"), asset-url("/assets/Jaapokki-Regular.ttf") format("truetype");
   font-weight: normal;
   font-style: normal;
}

but I get an error in the chrome development console of

GET https://mve.herokuapp.com/assets/Jaapokki-Regular.woff net::ERR_ABORTED

Now this works in development, and I have used a similar set-up when deploying to an aws server. However this app is deployed to heroku which seems to be giving me problems. I guess the first question is how can I check if my fonts are even compiling when pushing to production.

Any help is greatly appreciated thank!

evanshabsove
  • 157
  • 1
  • 14

2 Answers2

3

Since your fonts are in app/assets/fonts, you should be able to use font-url in your SCSS to automatically generate the correct asset path for each font file:

@font-face {
   font-family: 'Jaapokki';
   src: font-url("Jaapokki-Regular.eot");
   src: font-url("Jaapokki-Regular.eot?#iefix") format("embedded-opentype"),
        font-url("Jaapokki-Regular.woff") format("woff"),
        font-url("Jaapokki-Regular.ttf") format("truetype");
   font-weight: normal;
   font-style: normal;
}

See Aaron Gray's answer to a similar question here: https://stackoverflow.com/a/19414154/2076253

Jeremy
  • 3,833
  • 2
  • 22
  • 13
0
@font-face {
    font-family: "raty";
    src: url(asset-path("raty.woff"));
}
Jeremy Caney
  • 7,102
  • 69
  • 48
  • 77
Jr. dhh
  • 23
  • 6
  • To help readers better understand the difference between this and the accepted answer, can you explain the conditions under which your approach would be preferred, and what the differences in behavior might be? – Jeremy Caney May 22 '21 at 22:17