erikflowers / weather-icons

215 Weather Themed Icons and CSS
https://github.com/erikflowers/weather-icons
6.91k stars 851 forks source link

404 Errors when installed into Rails asset pipeline using rails-assets #111

Closed house9 closed 8 years ago

house9 commented 8 years ago

This is more of a question than an issue.

I just installed weather-icons into my Rails application as a 'rails-assets' gem (which leverages the bower.json file)

source 'https://rails-assets.org' do
  ...
  gem 'rails-assets-weather-icons'
end

Added the necessary require statement to my css manifest file and everything works great, except there are multiple 404 requests being made before it finally finds the font file.

See attached screenshots

image

image

As a work around I copied the font files to public/font

mkdir public/font
cp [RUBY_GEMS]/gems/rails-assets-weather-icons-2.0.10/app/assets/fonts/weather-icons/font/* public/font/

This got rid of the 404s (and loads the fonts much faster), just wondering if there is a better way to handle this?

Thanks!

erikflowers commented 8 years ago

I can't even begin to answer this or propose a solution. If the fonts are in the folder, obviously it wouldn't 404. But why it is not putting them in the folder through the gem, that's way out of my depth. I am open to any suggestions you have on how I could fix it though.

house9 commented 8 years ago

I looked into this some more. Turns out I was including 'all' of the source files which was adding the @font-face declaration multiple times, some of which still had the relative path and others with the correct asset pipeline path. i.e.

@font-face {
  font-family: 'weathericons';
  src: url(/assets/weather-icons/font/weathericons-regular-webfont.eot); 
  ...

AND

@font-face {
  font-family: 'weathericons';
  src: url(../font/weathericons-regular-webfont.eot); 
  ...

Changing the asset pipeline require statement

No need to manually add fonts to the public directory.

Closing this issue.