我有一個Rails項目,在Heroku上託管,我剛搬到託管我的資產到S3。除了一些自定義字體(來自icomoon的SVG字體)之外,這一切都很流暢。他們不工作,當我查看我的網頁源,我可以看到我的S3存儲不會顯示出來:SVG字體與Rails資產管道和S3託管
@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)
等。然而,其他資產(圖片,樣式表等)主持了與S3請包含正確的存儲桶名稱。
我font-face
聲明是在.LESS文件(這並不需要是一個.less.erb文件是不是?)
@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;
}
我所有的字體是/app/assets/fonts
。我已經按照the accepted answer here中的步驟操作,但事實是我的存儲桶名稱沒有顯示出字體,這讓我相信這是一個不同的問題。
編輯
我使用這個asset_sync寶石,它的配置低於:
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
末
編譯之後,您是否使用任何gem將資源置於S3中?你可以附加它的配置嗎?文件是在桶裏還是根本沒有? –
是的,更新問題。這些文件位於存儲桶中(但它們不在子文件夾中 - 所有字體,css,js都只在我在config中指定的主存儲區中) – jbnunn
,如果您使用asset-url helper(不確定名稱)? –