lib/inline_svg/railtie.rb in inline_svg-1.5.0 vs lib/inline_svg/railtie.rb in inline_svg-1.5.1
- old
+ new
@@ -8,18 +8,25 @@
end
end
config.after_initialize do |app|
InlineSvg.configure do |config|
- # In default Rails apps, this will be a fully operational
- # Sprockets::Environment instance
+ # Configure the asset_finder:
# Only set this when a user-configured asset finder has not been
# configured already.
if config.asset_finder.nil?
if assets = app.instance_variable_get(:@assets)
+ # In default Rails apps, this will be a fully operational
+ # Sprockets::Environment instance
config.asset_finder = assets
elsif defined?(Webpacker)
+ # Use Webpacker when it's available
config.asset_finder = InlineSvg::WebpackAssetFinder
+ else
+ # Fallback to the StaticAssetFinder if all else fails.
+ # This will be used in cases where assets are precompiled and other
+ # production settings.
+ config.asset_finder = InlineSvg::StaticAssetFinder
end
end
end
end
end