FIX: Include extra SCSS in child theme (#11952)

This commit is contained in:
Penar Musaraj 2021-02-03 11:02:53 -05:00 committed by GitHub
parent db7b7eed9d
commit 2309032e68
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 4 deletions

View File

@ -193,10 +193,21 @@ module Stylesheet
// Theme: #{field.theme.name}
// Target: #{field.target_name} #{field.name}
// Last Edited: #{field.updated_at}
#{value}
COMMENT
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
end
end
end
contents
end

View File

@ -795,13 +795,16 @@ HTML
expect(css).to include("p{color:blue}")
end
it "works for child themes" do
it "works for child themes and includes child theme SCSS in parent theme" do
child_theme.set_field(target: :common, name: :scss, value: '@import "my_files/moremagic"')
child_theme.save!
manager = Stylesheet::Manager.new(:desktop_theme, child_theme.id)
css, _map = manager.compile(force: true)
expect(css).to include("body{background:green}")
parent_css, _parent_map = compiler
expect(parent_css).to include("body{background:green}")
end
end

View File

@ -38,7 +38,7 @@ describe ThemesInstallTask do
end
let :scss_data do
"@font-face { font-family: magic; src: url($font)}; body {color: $color; content: $name;}"
"@font-face { font-family: magic; src: url($font)}; body {color: fuchsia;}"
end
let :theme_repo do