gpt4 book ai didi

ruby-on-rails - S3 CDN + 字体 + Rails 3.2 Assets 管道

转载 作者:行者123 更新时间:2023-12-01 21:15:12 25 4
gpt4 key购买 nike

类似于这篇文章:SVG Fonts with Rails Asset Pipeline and S3 Hosting , 我也有同样的问题。

我有以下/assets/stylesheets/ace-fonts.less 文件

@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;
}

我正在使用 less-rails Gem (https://github.com/metaskills/less-rails)。

我的 /environments/development.rb 中有这个:

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

当我部署时,自定义字体的 URL 未正确呈现,如下所示。存储桶名称丢失。

@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
}

但是,字体已正确上传到 S3。此外,其他帮助程序(例如 image_tag)也适用于图像。

我正在使用https://github.com/rumblelabs/asset_sync Gem,asset_sync.rb 文件如下所示:

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

最佳答案

您的 ENV['AWS_S3_BUCKET'] 为空

关于ruby-on-rails - S3 CDN + 字体 + Rails 3.2 Assets 管道,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20793423/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com