scinote-web/config/initializers/asset_url_processor.rb
2023-07-06 13:26:41 +02:00

11 lines
359 B
Ruby

class AssetUrlProcessor
def self.call(input)
context = input[:environment].context_class.new(input)
data = input[:data].gsub(/(\w*)-url\(\s*["']?(?!(?:\#|data|http))([^"'\s)]+)\s*["']?\)/) do |_match|
"url(#{context.asset_path($2, type: $1)})"
end
{data: data}
end
end
Sprockets.register_postprocessor "text/css", AssetUrlProcessor