mirror of
https://github.com/discourse/discourse.git
synced 2025-05-29 22:18:08 +08:00
FIX: Move CORE_SVG_SPRITES constant to a method (#32261)
Changing the `CORE_SVG_SPRITES` constant to a method enables us to
detect SVG files that are written to the vendor directory during plugin
initialization (as done by the [FontAwesome pro
plugin](79a8d39fb4/plugin.rb (L31)
))
which happens after all the ruby classes/files are read and loaded into
memory.
Internal topic: t/151476.
This commit is contained in:
@ -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
|
||||
|
Reference in New Issue
Block a user