Skip to content

Commit

Permalink
Cache precompiled inline svgs, so they work with assets.compile = fal…
Browse files Browse the repository at this point in the history
…se in prod
  • Loading branch information
DanielJackson-Oslo committed Jan 28, 2024
1 parent aa76f70 commit 7bd0aef
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions config/initializers/inilne_svg_cache.rb
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 7bd0aef

Please sign in to comment.