mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 14:03:22 +08:00
DEV: Plugin scss errors should break precompile (#6974)
This commit is contained in:
parent
6c195640b9
commit
d639cadb7a
|
@ -105,6 +105,8 @@ module Discourse
|
||||||
|
|
||||||
class Deprecation < StandardError; end
|
class Deprecation < StandardError; end
|
||||||
|
|
||||||
|
class ScssError < StandardError; end
|
||||||
|
|
||||||
def self.filters
|
def self.filters
|
||||||
@filters ||= [:latest, :unread, :new, :read, :posted, :bookmarks]
|
@filters ||= [:latest, :unread, :new, :read, :posted, :bookmarks]
|
||||||
end
|
end
|
||||||
|
|
|
@ -6,16 +6,6 @@ module Stylesheet
|
||||||
|
|
||||||
class Compiler
|
class Compiler
|
||||||
|
|
||||||
def self.error_as_css(error, label)
|
|
||||||
error = error.message
|
|
||||||
error.gsub!("\n", '\A ')
|
|
||||||
error.gsub!("'", '\27 ')
|
|
||||||
|
|
||||||
"#main { display: none; }
|
|
||||||
body { white-space: pre; }
|
|
||||||
body:before { font-family: monospace; content: '#{error}' }"
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.compile_asset(asset, options = {})
|
def self.compile_asset(asset, options = {})
|
||||||
|
|
||||||
if Importer.special_imports[asset.to_s]
|
if Importer.special_imports[asset.to_s]
|
||||||
|
|
|
@ -166,15 +166,11 @@ class Stylesheet::Manager
|
||||||
source_map_file: source_map_filename
|
source_map_file: source_map_filename
|
||||||
)
|
)
|
||||||
rescue SassC::SyntaxError => e
|
rescue SassC::SyntaxError => e
|
||||||
|
|
||||||
# we do not need this reported as we will report it in the UI anyway
|
|
||||||
Rails.logger.info "Failed to compile #{@target} stylesheet: #{e.message}"
|
|
||||||
|
|
||||||
if %w{embedded_theme mobile_theme desktop_theme}.include?(@target.to_s)
|
if %w{embedded_theme mobile_theme desktop_theme}.include?(@target.to_s)
|
||||||
# no special errors for theme, handled in theme editor
|
# no special errors for theme, handled in theme editor
|
||||||
["", nil]
|
["", nil]
|
||||||
else
|
else
|
||||||
[Stylesheet::Compiler.error_as_css(e, "#{@target} stylesheet"), nil]
|
raise Discourse::ScssError, e.message
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -58,7 +58,8 @@ task 'assets:precompile:css' => 'environment' do
|
||||||
STDERR.puts "Compiling css for #{db} #{Time.zone.now}"
|
STDERR.puts "Compiling css for #{db} #{Time.zone.now}"
|
||||||
begin
|
begin
|
||||||
Stylesheet::Manager.precompile_css
|
Stylesheet::Manager.precompile_css
|
||||||
rescue => PG::UndefinedColumn
|
rescue PG::UndefinedColumn => e
|
||||||
|
STDERR.puts "#{e.class} #{e.message}: #{e.backtrace.join("\n")}"
|
||||||
STDERR.puts "Skipping precompilation of CSS cause schema is old, you are precompiling prior to running migrations."
|
STDERR.puts "Skipping precompilation of CSS cause schema is old, you are precompiling prior to running migrations."
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user