Sha256: a44edfa0e50d56013a726f44617176bde771e725c55cea08c38f99b7e61c8255

Contents?: true

Size: 1.11 KB

Versions: 20

Compression:

Stored size: 1.11 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) ? # rubocop:disable Style/MultilineTernaryOperator
                                       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

20 entries across 20 versions & 1 rubygems

Version Path
hanami-assets-1.3.1 lib/hanami/assets/compressors/sass_stylesheet.rb
hanami-assets-1.3.0 lib/hanami/assets/compressors/sass_stylesheet.rb
hanami-assets-1.3.0.beta1 lib/hanami/assets/compressors/sass_stylesheet.rb
hanami-assets-1.2.0 lib/hanami/assets/compressors/sass_stylesheet.rb
hanami-assets-1.2.0.rc2 lib/hanami/assets/compressors/sass_stylesheet.rb
hanami-assets-1.2.0.rc1 lib/hanami/assets/compressors/sass_stylesheet.rb
hanami-assets-1.2.0.beta2 lib/hanami/assets/compressors/sass_stylesheet.rb
hanami-assets-1.2.0.beta1 lib/hanami/assets/compressors/sass_stylesheet.rb
hanami-assets-1.1.1 lib/hanami/assets/compressors/sass_stylesheet.rb
hanami-assets-1.1.0 lib/hanami/assets/compressors/sass_stylesheet.rb
hanami-assets-1.1.0.rc1 lib/hanami/assets/compressors/sass_stylesheet.rb
hanami-assets-1.1.0.beta3 lib/hanami/assets/compressors/sass_stylesheet.rb
hanami-assets-1.1.0.beta2 lib/hanami/assets/compressors/sass_stylesheet.rb
hanami-assets-1.1.0.beta1 lib/hanami/assets/compressors/sass_stylesheet.rb
hanami-assets-1.0.0 lib/hanami/assets/compressors/sass_stylesheet.rb
hanami-assets-1.0.0.rc1 lib/hanami/assets/compressors/sass_stylesheet.rb
hanami-assets-1.0.0.beta2 lib/hanami/assets/compressors/sass_stylesheet.rb
hanami-assets-1.0.0.beta1 lib/hanami/assets/compressors/sass_stylesheet.rb
hanami-assets-0.4.0 lib/hanami/assets/compressors/sass_stylesheet.rb
hanami-assets-0.3.0 lib/hanami/assets/compressors/sass_stylesheet.rb