I want to do the following
if build?
assetPath = "//cdn.domain.com/assets"
else
assetPath = "assets"
end
trying all combinations and reading everywhere but simply stumped at the moment
ruby and middleman - still learning.
你在尝试这个config.rb
吗?如果没有,你应该这样做。
已经有一个您可能想要使用的设置...
set :css_dir, 'assets'
...并在构建时更改:
configure :build do
set :css_dir, '//cdn.domain.com/assets'
end
您知道资产助手吗?您可以使用 ...
<%= stylesheet_link_tag 'foo.css' %>
...在您的 (ERB) 模板中。
在开发时应该给你...
<link href="/assets/foo.css" media="screen" rel="stylesheet" type="text/css" />
...在您的构建中:
<link href="//cdn.domain.com/assets/foo.css" media="screen" rel="stylesheet" type="text/css" />
我实际上对早期答案有疑问。要实际更改资产路径以使用 CloudFront 等 CDN,我必须执行以下操作:
# Fingerprint assets
activate :asset_hash
# Enable Asset Hosts
activate :asset_host
set :asset_host do |asset|
'//d23xxk856.cloudfront.net'.to_s
end