Created
January 29, 2018 07:53
-
-
Save peyloride/7210de675801e9a4766856e8102aa589 to your computer and use it in GitHub Desktop.
Rails detect failed .css or .scss file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Source: https://stackoverflow.com/questions/41649496/error-precompiling-assets-when-moving-to-production/41650364#41650364 | |
namespace :assets do | |
desc "Find Sass::SyntaxError files..." | |
task find_scss_with_error: :environment do | |
files = Dir.glob( Rails.root.join("app", "assets", "stylesheets", "**/*")).grep(/.*\.[css|scss]/) | |
files.each do |file| | |
print "Trying to compile #{file}..." | |
template = File.read(file) | |
sass_engine = Sass::Engine.new(template) | |
begin | |
sass_engine.render | |
print "[OK]" | |
rescue | |
print "[ERROR]" | |
end | |
puts | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment