Skip to content

A platform for community discussion. Free, open, simple.

FIX: Move CORE_SVG_SPRITES constant to a method (#32261)

Osama Sayeghd416b64af0e6
diff --git a/lib/svg_sprite.rb b/lib/svg_sprite.rb
index 61c51c61098..a54ddc851ce 100644
--- a/lib/svg_sprite.rb
+++ b/lib/svg_sprite.rb
@@ -264,8 +264,6 @@ module SvgSprite
],
)
- CORE_SVG_SPRITES = Dir.glob("#{Rails.root}/vendor/assets/svg-icons/**/*.svg")
-
THEME_SPRITE_VAR_NAME = "icons-sprite"
MAX_THEME_SPRITE_SIZE = 1024.kilobytes
@@ -293,9 +291,13 @@ module SvgSprite
.to_h
end
+ def self.core_svgs_files
+ @svg_files ||= Dir.glob("#{Rails.root}/vendor/assets/svg-icons/**/*.svg")
+ end
+
def self.core_svgs
@core_svgs ||=
- CORE_SVG_SPRITES.reduce({}) do |symbols, path|
+ core_svgs_files.reduce({}) do |symbols, path|
symbols.merge!(symbols_for(File.basename(path, ".svg"), File.read(path), strict: true))
end
end