diff --git a/config/initializers/inilne_svg_cache.rb b/config/initializers/inilne_svg_cache.rb new file mode 100644 index 00000000..1bc4dc46 --- /dev/null +++ b/config/initializers/inilne_svg_cache.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +# This caches all SVGs in assets folder, and solves inline svg for +# production use. + +InlineSvg.configure do |config| + # Only precompile if we aren't compiling on the fly + return if Rails.application.config.assets.compile + + assets_path = Rails.public_path.join("assets").to_s + return unless Dir.exist? assets_path + + config.asset_file = InlineSvg::CachedAssetFile.new( + paths: [ + assets_path + ], + filters: /\.svg/ + ) +end