Sha256: 812ef7be13dd617ef5c591a70853536a7c38d96e13e8315a9cc2e2e15d6796ac

Contents?: true

Size: 1.04 KB

Versions: 2

Compression:

Stored size: 1.04 KB

Contents

require 'hanami/assets/compressors/stylesheet'
require 'sass'

module Hanami
  module Assets
    module Compressors
      # Sass compressor for stylesheet
      #
      # It depends on <tt>sass</tt> gem.
      #
      # @since 0.1.0
      # @api private
      #
      # @see http://sass-lang.com
      # @see https://rubygems.org/gems/sass
      class SassStylesheet < Stylesheet
        # @since 0.1.0
        # @api private
        #
        # FIXME This is the same logic that we have for Hanami::Assets::Compiler
        SASS_CACHE_LOCATION = Pathname(Hanami.respond_to?(:root) ?
                                       Hanami.root : Dir.pwd).join('tmp', 'sass-cache')
        # @since 0.1.0
        # @api private
        def initialize
          @compressor = Sass::Engine
        end

        # @since 0.1.0
        # @api private
        def compress(filename)
          compressor.new(read(filename), filename: filename, syntax: :scss,
            style: :compressed, cache_location: SASS_CACHE_LOCATION).render
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
hanami-assets-0.2.1 lib/hanami/assets/compressors/sass_stylesheet.rb
hanami-assets-0.2.0 lib/hanami/assets/compressors/sass_stylesheet.rb