Search code examples
ruby-on-railsrubynginxpassengersemantic-ui

Rails Nginx Passenger not serving font icon files


I am running a Rails 5.1.4 app in production mode. I am using Semantic UI as my css framework and have already ran RAILS_ENV=production rails assets:precompile to compile my assets and font files in the public/assets folder. When I load my website everything works except the icons are replaced by squares.

Here is my config/application.rb:

class Application < Rails::Application
  config.load_defaults 5.1

  config.assets.paths << Rails.root.join('semantic', 'dist')
  config.assets.precompile << 'themes/default/assets/fonts/*'
end

My Nginx file:

server {
    listen       80;
    server_name  atrium.michaelvasallo.com;
    passenger_enabled on;
    rails_env production;
    root /var/www/atrium/public;
}

As you can see Semantic UI is looking in themes/default/assets/fonts/ and that is where my icon files are located. They are all showing up in the public/assets folder when I precompile but they are not being served when the page is loaded.


Solution

  • Not a fix, but I found a better solution. In my semantic/src/site/globals/site.variables I set the font path to the Semantic UI CDN instead of fetching from local files.

    @fontPath: 'https://cdn.jsdelivr.net/npm/[email protected]/dist/themes/default/assets/fonts';