在Rails 7.0.0.alpha的生产环境中的资产管道



大家好,这个问题让我有点困惑,我觉得我一直在原地打转。我正试图让我的资产从CDN(在本例中为AWS/Cloudfront)提供服务

资产通过CI服务器预编译并部署到S3 bucket,并且运行良好。

我已经阅读了指南,我认为我已经设置了config/environments/production.rb校正如下:

# Disable serving static files from the `/public` folder by default since
# Apache or NGINX already handles this.
# config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
# Compress CSS using a preprocessor.
# config.assets.css_compressor = :sass
# Do not fallback to assets pipeline if a precompiled asset is missed.
config.assets.compile = false
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
config.asset_host = ENV['RAILS_ASSET_HOST']
# Specifies the header that your server uses for sending files.
# config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX

我已经调试了环境变量RAILS_ASSET_HOST正确设置为https://asset.mycdn.com,但无论我做什么,我继续得到以下错误:

ActionView::Template::Error (The asset "application.css" is not present in the asset pipeline.

感谢任何帮助。我肯定这是什么愚蠢的东西,只是盯着看太久了!

回想起来,您需要在应用服务器上拥有生成的清单文件,否则rails无法将application.css转换为相应的application-SOME_SHA.css

最新更新