scinote-web/config/initializers/asset_url_processor.rb

12 lines
359 B
Ruby
Raw Normal View History

2023-07-06 19:19:28 +08:00
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