Skip to content

Instantly share code, notes, and snippets.

@peyloride
Created January 29, 2018 07:53
Show Gist options
  • Save peyloride/7210de675801e9a4766856e8102aa589 to your computer and use it in GitHub Desktop.
Save peyloride/7210de675801e9a4766856e8102aa589 to your computer and use it in GitHub Desktop.
Rails detect failed .css or .scss file
#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