From 9924af653daf9484681a308c0e123bdc16da08aa Mon Sep 17 00:00:00 2001 From: Micah Geisel Date: Fri, 15 May 2020 13:04:00 -0700 Subject: [PATCH] define the asset_url function in the right context. --- lib/sassc/rails/functions.rb | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/lib/sassc/rails/functions.rb b/lib/sassc/rails/functions.rb index fbb84dc..ab195cb 100644 --- a/lib/sassc/rails/functions.rb +++ b/lib/sassc/rails/functions.rb @@ -1,13 +1,17 @@ # frozen_string_literal: true -require 'sprockets/sass_functions' +begin + require 'sprockets/sassc_processor' + mod = Sprockets::SasscProcessor::Functions +rescue LoadError + require 'sprockets/sass_functions' + mod = Sprockets::SassFunctions +end -module Sprockets - module SassFunctions - def asset_data_url(path) - ::SassC::Script::Value::String.new("url(" + sprockets_context.asset_data_uri(path.value) + ")") - end +mod.instance_eval do + def asset_data_url(path) + ::SassC::Script::Value::String.new("url(" + sprockets_context.asset_data_uri(path.value) + ")") end end -::SassC::Script::Functions.send :include, Sprockets::SassFunctions +::SassC::Script::Functions.send :include, mod