3

Similar to this post: SVG Fonts with Rails Asset Pipeline and S3 Hosting, I have the same problem.

I have the following /assets/stylesheets/ace-fonts.less file

@font-face {
  font-family: 'Icarus';
  src:  font-url('Lato-Reg-webfont.eot');
  src:  font-url('Lato-Reg-webfont.eot?#iefix') format("embedded-opentype"),
  font-url('Lato-Reg-webfont.woff') format("woff"),
  font-url('Lato-Reg-webfont.ttf') format("truetype"),
  font-url('Lato-Reg-webfont.svg#LatoReg') format("svg") ;
  font-weight: normal;
  font-style: normal;
}

I'm using less-rails Gem (https://github.com/metaskills/less-rails).

I have this in my /environments/production.rb:

config.action_controller.asset_host =  "//#{ENV['AWS_S3_BUCKET']}.s3.amazonaws.com"

When I deploy, the custom font's URL is not rendered correctly, as seen below. The bucket name is missing.

@font-face{
font-family:'Icarus';
src:url(//.s3.amazonaws.com/assets/Lato-Reg-webfont-f6c86163de8607e667ad9b51218ab21c.eot);
src:url(//.s3.amazonaws.com/assets/Lato-Reg-webfont.eot?#iefix) format("embedded-opentype"),
url(//.s3.amazonaws.com/assets/Lato-Reg-webfont-0ab907b50400c2e1577aa82531bb5a27.woff) format("woff"),
url(//.s3.amazonaws.com/assets/Lato-Reg-webfont-fe3f3ba10b31ca6404e975e2cf4f3621.ttf) format("truetype"),
url(//.s3.amazonaws.com/assets/Lato-Reg-webfont.svg#LatoReg) format("svg");
font-weight:normal;
font-style:normal
}

However, the fonts are correctly uploaded to S3. Also, other helpers such as image_tag are working for images.

I'm using https://github.com/rumblelabs/asset_sync Gem, the asset_sync.rb file looks like this:

if defined?(AssetSync)
  AssetSync.configure do |config|
    config.fog_provider = 'AWS'
    config.aws_access_key_id = ENV['AWS_ACCESS_KEY_ID']
    config.aws_secret_access_key = ENV['AWS_SECRET_ACCESS_KEY']
    # To use AWS reduced redundancy storage.
    # config.aws_reduced_redundancy = true
    config.fog_directory = ENV['AWS_S3_BUCKET']

    # Invalidate a file on a cdn after uploading files
    # config.cdn_distribution_id = "12345"
    # config.invalidate = ['file1.js']

    # Increase upload performance by configuring your region
    config.fog_region = 'us-west-2'

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

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

    # Use the Rails generated 'manifest.yml' file to produce the list of files to
    # upload instead of searching the assets directory.
    #config.manifest = true

    # Fail silently.  Useful for environments such as Heroku
    config.fail_silently = true
  end
end
Community
  • 1
  • 1
netwire
  • 7,108
  • 12
  • 52
  • 86

1 Answers1

0

Your ENV['AWS_S3_BUCKET'] is blank

ck3g
  • 5,829
  • 3
  • 32
  • 52