我正在使用Assets Sync在部署时将资产上传到 S3。所有资产均已正确上传并存储在 S3 上。
应用中使用的js、css、字体均指向S3,图片除外
我想问题可能出在rails应用程序上......
到底是怎么回事?
我的初始化程序配置文件:
AssetSync.configure do |config|
config.fog_provider = 'AWS'
config.fog_directory = ENV['FOG_DIRECTORY']
config.aws_access_key_id = ENV['AWS_ACCESS_KEY_ID']
config.aws_secret_access_key = ENV['AWS_SECRET_ACCESS_KEY']
# Don't delete files from the store
# config.existing_remote_files = 'keep'
#
# Increase upload performance by configuring your region
# config.fog_region = 'eu-west-1'
#
# 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
配置/环境/staging.rb
MyApp::Application.configure do
routes.default_url_options[:host]= ENV['DOMAIN']
config.cache_classes = true
config.cache_store = :dalli_store
config.static_cache_control = "public, max-age=2592000"
config.action_controller.perform_caching = true
config.consider_all_requests_local = false
config.serve_static_assets = true
config.assets.compress = true
config.assets.compile = false
config.assets.digest = true
config.assets.enabled = true
config.assets.js_compressor = :uglifier
config.assets.precompile += %w(static.js static.css vendor.js)
config.assets.paths << Rails.root.join('app', 'assets', 'fonts')
config.action_controller.asset_host = "//#{ENV['FOG_DIRECTORY']}.s3.amazonaws.com"
config.assets.prefix = "/assets"
config.i18n.fallbacks = true
config.active_support.deprecation = :notify
end
谢谢!