mirror of
https://github.com/discourse/discourse.git
synced 2025-05-31 12:57:17 +08:00
PERF: Precompile child theme stylesheets. (#13040)
Previously, we only precompiled the CSS for parent themes but not for the child themes. As a result, the CSS for child themes were being compiled during the first request which made the respond time high for that request.
This commit is contained in:

committed by
GitHub

parent
a532e64389
commit
958b56dc6c
@ -164,13 +164,23 @@ class Stylesheet::Manager
|
||||
themes.each do |id, name, color_scheme_id|
|
||||
targets.each do |target|
|
||||
theme_id = id || SiteSetting.default_theme_id
|
||||
next if target =~ THEME_REGEX && theme_id == -1
|
||||
cache_key = "#{target}_#{theme_id}"
|
||||
|
||||
STDERR.puts "precompile target: #{target} #{name}"
|
||||
builder = self.new(target, theme_id)
|
||||
builder.compile(force: true)
|
||||
cache[cache_key] = nil
|
||||
if target =~ THEME_REGEX
|
||||
next if theme_id == -1
|
||||
|
||||
theme_ids = Theme.transform_ids([theme_id], extend: true)
|
||||
|
||||
theme_ids.each do |t_id|
|
||||
builder = self.new(target, t_id)
|
||||
STDERR.puts "precompile target: #{target} #{builder.theme.name}"
|
||||
next if builder.theme.component && !builder.theme.has_scss(target)
|
||||
builder.compile(force: true)
|
||||
end
|
||||
else
|
||||
STDERR.puts "precompile target: #{target} #{name}"
|
||||
builder = self.new(target, theme_id)
|
||||
builder.compile(force: true)
|
||||
end
|
||||
end
|
||||
|
||||
theme_color_scheme = ColorScheme.find_by_id(color_scheme_id) || ColorScheme.base
|
||||
|
Reference in New Issue
Block a user