2

I have a Rails project, hosted on Heroku, and I just moved hosting my assets to S3. This has all gone smooth EXCEPT for some custom fonts (SVG fonts from icomoon). They're not working, and when I view my web source, I can see that my S3 bucket doesn't show up:

@font-face{font-family:'Starter-Icons';src:url(https://.s3.amazonaws.com/fonts/Starter-Icons.eot);src:url(https://.s3.amazonaws.com/fonts/Starter-Icons.eot?#iefix) 

etc. However, other assets (images, stylesheets, etc) hosted with S3 do include the proper bucket name.

My font-face declarations are in a .less file (this doesn't need to be a .less.erb file does it?)

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

}

All my fonts are in /app/assets/fonts. I've followed the steps in the accepted answer here, but the fact that my bucket name isn't showing up for the fonts leads me to believe it's a different issue.

EDIT

I am using the asset_sync gem for this, its config is below:

if defined?(AssetSync)
  AssetSync.configure do |config|
  config.fog_provider = 'AWS'
  config.fog_directory = 'starterapp'

  config.aws_access_key_id = ENV['STARTER_AWS_ACCESS_KEY_ID']
  config.aws_secret_access_key = ENV['STARTER_AWS_SECRET_ACCESS_KEY']

  # Don't delete files from the store
  config.existing_remote_files = 'keep'

  # Automatically replace files with their equivalent gzip compressed version
  config.gzip_compression = true
end

end

Community
  • 1
  • 1
jbnunn
  • 6,161
  • 4
  • 40
  • 65
  • Do you use any gem to put assets in S3 after compilation? Can you attach it's config? Are the files in the bucket or not at all? – Mike Szyndel Jul 11 '13 at 06:03
  • Yes, updating question. The files are in the bucket (but they are not in sub-folders--all fonts, css, js are just in the main bucket I specified in config) – jbnunn Jul 11 '13 at 14:53
  • and if you'd use asset-url helper (not sure about the name)? – Mike Szyndel Jul 11 '13 at 14:58
  • Yes definitely, the font helper is `font-url`, it builds it out perfectly EXCEPT for the bucket name. `image_tag` and the other asset helpers DO grab the bucket name. So, images, stylesheets, script tags, etc, all use asset-url helpers and work fine. `font-url` is the one being tricky. – jbnunn Jul 11 '13 at 15:02
  • Found this thread, may be useful http://stackoverflow.com/questions/10905905/using-fonts-with-rails-asset-pipeline – Mike Szyndel Jul 11 '13 at 15:12
  • Were you able to resolve this? I have the same problem. – netwire Dec 27 '13 at 01:01

1 Answers1

0

Well, (un)fortunately -- it works now, and all I did is bundle exec rake assets:precompile (again) and push to Heroku (again). The bundle exec rake assets:precompile cleared out the old compiled css/js/font files, and built new ones. I did this step previously and didn't get these results, so I'm not sure how it's even working.

This could've been user error--I don't see how this actually made it work. Another confusing thing is running

irb(main):001:0> Rails.application.config.assets.paths

returns

=> ["/app/app/assets/fonts", "/app/app/assets/images", "/app/app/assets/javascripts", "/app/app/assets/stylesheets"

and I'm not sure how /app/app/assets is getting created on production vs /app/assets/ on development, but, it works.

jbnunn
  • 6,161
  • 4
  • 40
  • 65
  • I have faced same issue. Please help if possible https://stackoverflow.com/questions/52869346/rails-4-custom-asset-path-added-in-application-rb-without-restart – ray Oct 25 '18 at 08:27