FIX: Improve SCSS handling in components (#11963)

- ignores errors when including component SCSS in parent theme
- adds support for SCSS `@import`s in components' `color_definitions.scss` files
This commit is contained in:
Penar Musaraj
2021-02-04 08:51:18 -05:00
committed by GitHub
parent b580e3e657
commit 12ffba771c
4 changed files with 33 additions and 13 deletions

View File

@ -141,9 +141,15 @@ module Stylesheet
if resolved_ids
theme = Theme.find_by_id(theme_id)
contents << theme&.scss_variables.to_s
Theme.list_baked_fields(resolved_ids, :common, :color_definitions).each do |row|
contents << "// Color definitions from #{theme.name}\n\n"
contents << row.value
Theme.list_baked_fields(resolved_ids, :common, :color_definitions).each do |field|
contents << "// Color definitions from #{field.theme.name}\n\n"
if field.theme_id == theme.id
contents << field.value
else
contents << field.compiled_css
end
contents << "\n\n"
end
end
contents
@ -198,13 +204,7 @@ module Stylesheet
if field.theme_id == theme.id
contents << value
else
css, source_map = begin
field.compile_scss
rescue SassC::SyntaxError => e
raise Discourse::ScssError, e.message
end
contents << css
contents << field.compiled_css
end
end