Rails 6 displays Font Awesome emojis in square when running environment

Asked 2 years ago, Updated 2 years ago, 110 views

  • Ruby 2.6.3
  • Ruby on Rails 6.0.0
  • Yarn 1.22.4
  • Webpacker 5.1.1
  • @fortawsome/fontawsome-free 5.13.0

As per the article (https://techracho.bpsinc.jp/hachi8833/2020_01_17/85943), we deployed the Fontawesome package in Yarn in Rails and configured it as follows:

application.scss

$fa-font-path: '@fortawesome/fontawesome-free/webfontts';
@import'@fortawesome/fontawsome-free/scss/fontawsome';
@import'@fortawsome/fontawsome-free/scss/regular';
@import'@fortawsome/fontawsome-free/scss/solid';
@import'@fortawsome/fontawsome-free/scss/brands';

application.js

require("@fortawsome/fontawsome-free")

In the development environment (localhost:3000), there were no errors on the Chrome development console and terminal, and emojis were displayed, but in the execution environment, the emojis were displayed as □, and the following errors were received:

Chrome console

Failed to load resource: the server responded with a status of 404 (Not Found) fa-solid-900.woff2:1
Failed to load resource: the server responded with a status of 404 (Not Found) fa-solid-900.woff:1
Failed to load resource: the server responded with a status of 404 (Not Found) fa-solid-900.tff:1

Terminal

ActionController:: RoutingError (No route matches [GET]"/assets/@fortawsome/fontawsome-free/webfonts/fa-solid-900.woff"):
...

I don't know why emojis are displayed in the development environment and not in the execution environment.

As I am a beginner, I understand that this is a poor question, but I would appreciate it if you could help me.

ruby-on-rails webpack yarn

2022-09-29 21:22

1 Answers

Resolved by setting config.assets.compile=true in config/environments/production.rb.


2022-09-29 21:22

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.