mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
DEV: debundle plugin css assets and don't load if disabled (#7646)
This commit is contained in:
@@ -12,7 +12,7 @@ module Stylesheet
|
||||
|
||||
if Importer.special_imports[asset.to_s]
|
||||
filename = "theme_#{options[:theme_id]}.scss"
|
||||
file = "@import \"common/foundation/variables\"; @import \"theme_variables\"; @import \"#{asset}\";"
|
||||
file = "@import \"common/foundation/variables\"; @import \"common/foundation/mixins\"; @import \"theme_variables\"; @import \"#{asset}\";"
|
||||
else
|
||||
filename = "#{asset}.scss"
|
||||
path = "#{ASSET_ROOT}/#{filename}"
|
||||
|
||||
@@ -19,16 +19,19 @@ module Stylesheet
|
||||
Import.new("#{theme_dir(@theme_id)}/theme_field.scss", source: @theme_field)
|
||||
end
|
||||
|
||||
register_import "plugins" do
|
||||
import_files(DiscoursePluginRegistry.stylesheets)
|
||||
end
|
||||
Discourse.plugins.each do |plugin|
|
||||
plugin_directory_name = plugin.directory_name
|
||||
|
||||
register_import "plugins_mobile" do
|
||||
import_files(DiscoursePluginRegistry.mobile_stylesheets)
|
||||
end
|
||||
["", "mobile", "desktop"].each do |type|
|
||||
asset_name = type.present? ? "#{plugin_directory_name}_#{type}" : plugin_directory_name
|
||||
stylesheets = type.present? ? DiscoursePluginRegistry.send("#{type}_stylesheets") : DiscoursePluginRegistry.stylesheets
|
||||
|
||||
register_import "plugins_desktop" do
|
||||
import_files(DiscoursePluginRegistry.desktop_stylesheets)
|
||||
if stylesheets[plugin_directory_name].present?
|
||||
register_import asset_name do
|
||||
import_files(stylesheets[plugin_directory_name])
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
register_import "plugins_variables" do
|
||||
|
||||
@@ -294,9 +294,9 @@ class Stylesheet::Manager
|
||||
# so we could end up poisoning the cache with a bad file that can not be removed
|
||||
def plugins_digest
|
||||
assets = []
|
||||
assets += DiscoursePluginRegistry.stylesheets.to_a
|
||||
assets += DiscoursePluginRegistry.mobile_stylesheets.to_a
|
||||
assets += DiscoursePluginRegistry.desktop_stylesheets.to_a
|
||||
DiscoursePluginRegistry.stylesheets.each { |_, paths| assets += paths.to_a }
|
||||
DiscoursePluginRegistry.mobile_stylesheets.each { |_, paths| assets += paths.to_a }
|
||||
DiscoursePluginRegistry.desktop_stylesheets.each { |_, paths| assets += paths.to_a }
|
||||
Digest::SHA1.hexdigest(assets.sort.join)
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user