This page looks best with JavaScript enabled

【Rails + Webpacker】CloudFrontの設定メモ

 ·  ☕ 1 分で読めます
1
2
3
4
group :production do
  gem 'asset_sync'
  gem 'fog-aws'
end
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
if defined?(AssetSync)
  AssetSync.configure do |config|
    config.fog_provider = 'AWS'
    config.aws_access_key_id = Rails.application.credentials.aws[:s3][:access_key_id]
    config.aws_secret_access_key = Rails.application.credentials.aws[:s3][:secret_access_key]

    # Use http instead of https. Default should be "https" (at least for fog-aws)
    # config.fog_scheme = "http"
    config.fog_directory = 'hashlog-s3'

    # Increase upload performance by configuring your region
    config.fog_region = 'ap-northeast-1'
  end
end
1
2
3
4
5
Rails.application.configure do
  # 以下の2行を追加
  config.action_controller.asset_host   = '//dp0oss8j47wvg.cloudfront.net'
  config.assets.prefix                  = '/assets'
end

Asset Sync を Webpacker と連携させる - Qiita
assets on S3を導入してみる | Cluex Developers Blog

Share on

aiandrox
Written by
aiandrox
今日も楽しく明日も楽しく

目次