Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display sass error in browser with livereload #160

Merged
merged 1 commit into from
Jan 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading