我正在尝试确保使用 Rails 资产管道提供压缩的 css 和 js 文件。我已经很好地设置了这一切,并且一切都在愉快地预编译 - 并且还愉快地同步到我使用 Amazon 的 CloudFront CDN 为它们提供服务的 S3。
我正在为 application.css 和 application.js 提供服务,如下所示:
= stylesheet_link_tag "application"
= javascript_include_tag "application"
简而言之,问题是:应用程序布局中没有输出带 MD5 后缀的文件——只有原始的 application.css 和 application.js
这有点奇怪:所有图像都有一个 MD5 标记。CSS/JS 文件没有。
这是我的production.config:
config.action_controller.perform_caching = true
# Specifies the header that your server uses for sending files
config.action_dispatch.x_sendfile_header = "X-Sendfile"
config.assets.compress = true
# Fallback to compile on demand
# config.assets.compile = true
#config.assets.precompile += %w(application.css application.js)
# Generate digests for assets URLs
config.assets.digest = true
#push the assets to amazon
config.action_controller.asset_host = Proc.new { |source, request|
if request.ssl?
"https://tekpub-assets.s3.amazonaws.com"
else
"http://tekpub-assets.s3.amazonaws.com"
end
}
config.serve_static_assets = false
整个过程令人生气的是我可以看到压缩/消化的文件——它们就在我的资产目录中。所有 em - CSS 和 JS 文件也是如此。
但是我的 manifest.yml 文件只更新如下:
---
application.js: application.js
application.css: application.css
当我运行预编译时没有错误 - 事实上一切看起来都很漂亮:
** Invoke assets:precompile:all (first_time)
** Execute assets:precompile:all
** Invoke assets:precompile:primary (first_time)
** Invoke assets:environment (first_time)
** Execute assets:environment
** Invoke environment (first_time)
** Execute environment
Resolved collector.newrelic.com to 204.93.223.153
AssetSync: using /Volumes/Fatty/Sites/tpub6/config/initializers/asset_sync.rb
** Invoke tmp:cache:clear (first_time)
** Execute tmp:cache:clear
** Execute assets:precompile:primary
** Invoke assets:precompile:nondigest (first_time)
** Invoke assets:environment (first_time)
** Execute assets:environment
** Invoke environment (first_time)
** Execute environment
Resolved collector.newrelic.com to 204.93.223.153
AssetSync: using /Volumes/Fatty/Sites/tpub6/config/initializers/asset_sync.rb
** Invoke tmp:cache:clear (first_time)
** Execute tmp:cache:clear
** Execute assets:precompile:nondigest
AssetSync: Syncing.
Using: Directory Search of /Volumes/Fatty/Sites/tpub6/public/assets
AssetSync: Done.
感谢您的任何指点/推动/提示。