Sha256: 64e07f1e7ae00cb717bb290c6a36edfa8d3347685b93ddd94334e87931b3629c

Contents?: true

Size: 974 Bytes

Versions: 12

Compression:

Stored size: 974 Bytes

Contents

# frozen_string_literal: true

require "sassc"

require "pakyow/assets/asset"

module Pakyow
  module Assets
    module Types
      class CSS < Asset
        extension :css

        def initialize(local_path:, config:, **kwargs)
          super

          @options = @config.sass.to_h
          @options[:filename] = @local_path.to_s
          @options[:syntax] = :scss

          if @config.source_maps
            @options[:source_map_file] = File.basename(@local_path.to_s)
          end
        end

        def process(content)
          @engine = ::SassC::Engine.new(content, @options)
          @engine.render
        rescue StandardError => error
          Pakyow.logger.error "[#{self.class}] #{error}"

          # Be sure to return a string.
          #
          content
        end

        def source_map_content
          ensure_content
          @engine.source_map
        rescue SassC::NotRenderedError
          nil
        end
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
pakyow-assets-1.0.6 lib/pakyow/assets/types/css.rb
pakyow-assets-1.0.5 lib/pakyow/assets/types/css.rb
pakyow-assets-1.0.4 lib/pakyow/assets/types/css.rb
pakyow-assets-1.0.3 lib/pakyow/assets/types/css.rb
pakyow-assets-1.0.2 lib/pakyow/assets/types/css.rb
pakyow-assets-1.0.1 lib/pakyow/assets/types/css.rb
pakyow-assets-1.0.0 lib/pakyow/assets/types/css.rb
pakyow-assets-1.0.0.rc5 lib/pakyow/assets/types/css.rb
pakyow-assets-1.0.0.rc4 lib/pakyow/assets/types/css.rb
pakyow-assets-1.0.0.rc3 lib/pakyow/assets/types/css.rb
pakyow-assets-1.0.0.rc2 lib/pakyow/assets/types/css.rb
pakyow-assets-1.0.0.rc1 lib/pakyow/assets/types/css.rb