-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cache precompiled inline svgs, so they work with assets.compile = fal…
…se in prod
- Loading branch information
1 parent
aa76f70
commit 7bd0aef
Showing
1 changed file
with
19 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |