lib/hanami/assets/compilers/sass.rb in hanami-assets-1.3.1 vs lib/hanami/assets/compilers/sass.rb in hanami-assets-1.3.2
- old
+ new
@@ -8,15 +8,10 @@
class Sass < Compiler
# @since 0.3.0
# @api private
EXTENSIONS = /\.(sass|scss)\z/.freeze
- # @since 0.1.0
- # @api private
- CACHE_LOCATION = Pathname(Hanami.respond_to?(:root) ? # rubocop:disable Style/MultilineTernaryOperator
- Hanami.root : Dir.pwd).join('tmp', 'sass-cache')
-
# @since 0.3.0
# @api private
def self.eligible?(name)
name.to_s =~ EXTENSIONS
end
@@ -24,22 +19,31 @@
private
# @since 0.3.0
# @api private
def renderer
- Tilt.new(source, nil, load_paths: load_paths, cache_location: CACHE_LOCATION)
+ @renderer ||=
+ ::SassC::Engine.new(
+ source.read,
+ syntax: target_syntax,
+ load_paths: load_paths
+ )
end
# @since 0.3.0
# @api private
def dependencies
- engine.dependencies.map { |d| d.options[:filename] }
+ renderer.dependencies.map(&:filename)
end
- # @since 0.3.0
+ # @since 1.3.2
# @api private
- def engine
- ::Sass::Engine.for_file(source.to_s, load_paths: load_paths, cache_location: CACHE_LOCATION)
+ def target_syntax
+ if source.extname =~ /sass\z/.freeze
+ :sass
+ else
+ :scss
+ end
end
end
end
end
end