DEV: Use separate files for theme component stylesheets (#12214)

This switches to outputting a separate file for each theme component CSS
asset. We have separate CSS plugin files, separate JS files
(for plugins/themes/components), it makes sense to do the same for
component CSS assets.

Benefits:
- easier debugging
- fixes a regression with theme component sourcemaps
- changes to theme components are updated individually

With HTTP/2, there is also no performance downside to having additional
files in the initial request.
This commit is contained in:
Penar Musaraj
2021-02-26 07:44:15 -05:00
committed by GitHub
parent bb3d5e9758
commit f57a49c2f9
6 changed files with 41 additions and 31 deletions

View File

@ -315,8 +315,7 @@ class Theme < ActiveRecord::Base
if all_themes
message = theme_ids.map { |id| refresh_message_for_targets(targets, id) }.flatten
else
parent_ids = Theme.where(id: theme_ids).joins(:parent_themes).pluck(:parent_theme_id).uniq
message = refresh_message_for_targets(targets, theme_ids | parent_ids).flatten
message = refresh_message_for_targets(targets, theme_ids).flatten
end
MessageBus.publish('/file-change', message)
@ -372,7 +371,7 @@ class Theme < ActiveRecord::Base
end
def list_baked_fields(target, name)
theme_ids = Theme.transform_ids([id])
theme_ids = Theme.transform_ids([id], extend: false)
self.class.list_baked_fields(theme_ids, target, name)
end