From 2309032e68bee6cca33c0d7b065b42aea12bf745 Mon Sep 17 00:00:00 2001 From: Penar Musaraj Date: Wed, 3 Feb 2021 11:02:53 -0500 Subject: [PATCH] FIX: Include extra SCSS in child theme (#11952) --- lib/stylesheet/importer.rb | 15 +++++++++++++-- spec/models/theme_spec.rb | 5 ++++- spec/services/themes_spec.rb | 2 +- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/lib/stylesheet/importer.rb b/lib/stylesheet/importer.rb index 8e15639aff7..20989916522 100644 --- a/lib/stylesheet/importer.rb +++ b/lib/stylesheet/importer.rb @@ -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 diff --git a/spec/models/theme_spec.rb b/spec/models/theme_spec.rb index b828447cf12..eca11336a00 100644 --- a/spec/models/theme_spec.rb +++ b/spec/models/theme_spec.rb @@ -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 diff --git a/spec/services/themes_spec.rb b/spec/services/themes_spec.rb index 4e5c01eea79..8db6db6a287 100644 --- a/spec/services/themes_spec.rb +++ b/spec/services/themes_spec.rb @@ -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