Here is my hacky but actually pretty functional solution:
# microsite1.com/index.haml
- if development? then $asset_base = "/microsite1.com" end
# config.rb
configure :development do
helpers do
alias_method :original_asset_path, :asset_path
def asset_path(*args)
path = original_asset_path(*args)
if not path =~ ABSOLUTE_URL_PATTERN && defined? $asset_base
path = File.join($asset_base, path)
end
path
end
end
end
tl;dr I'm hooking asset_path
to guarantee that all relative assets (stylesheets, javascripts, images) are prefixed with some $asset_base
path if specified. (If someone better at Ruby + Middleman than me wants to advise how I might do this without a global variable, I'm all ears.)