Skip to content

Commit

Permalink
Display sass error in browser with livereload (#160)
Browse files Browse the repository at this point in the history
Merge pull request 160
  • Loading branch information
ntkme authored Jan 1, 2024
1 parent e58afb8 commit a64eb8c
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lib/jekyll/converters/scss.rb
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,11 @@ def convert(content)
result
rescue ::Sass::CompileError => e
Jekyll.logger.error e.full_message
raise SyntaxError, e.message
if livereload? && e.respond_to?(:to_css)
e.to_css
else
raise SyntaxError, e.message
end
end

private
Expand All @@ -184,6 +188,11 @@ def associate_page_failed?
!sass_page
end

# Returns `true` if jekyll is serving with livereload.
def livereload?
!!@config["serving"] && !!@config["livereload"]
end

# The URL of the input scss (or sass) file. This information will be used for error reporting.
def sass_file_url
return if associate_page_failed?
Expand Down

0 comments on commit a64eb8c

Please sign in to comment.