Sha256: 6448d673ed6f5bac551d3ae1a81e282e9d862b99fa7ba088467d18c91858b32f

Contents?: true

Size: 824 Bytes

Versions: 6

Compression:

Stored size: 824 Bytes

Contents

require 'pathname'

module AutoprefixerRails
  # Register autoprefixer postprocessor in Sprockets and fix common issues
  class Sprockets
    def initialize(processor)
      @processor = processor
    end

    # Add prefixes for `css`
    def process(context, css, opts)
      input  = context.pathname.to_s
      output = input.chomp(File.extname(input)) + '.css'
      result = @processor.process(css, opts.merge(from: input, to: output))

      result.warnings.each do |warning|
        $stderr.puts "autoprefixer: #{ warning }"
      end

      result.css
    end

    # Register postprocessor in Sprockets depend on issues with other gems
    def install(assets, opts = {})
      assets.register_postprocessor('text/css', :autoprefixer) do |context, css|
        process(context, css, opts)
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
autoprefixer-rails-5.2.1.3 lib/autoprefixer-rails/sprockets.rb
autoprefixer-rails-5.2.1.2 lib/autoprefixer-rails/sprockets.rb
autoprefixer-rails-5.2.1.1 lib/autoprefixer-rails/sprockets.rb
autoprefixer-rails-5.2.1 lib/autoprefixer-rails/sprockets.rb
autoprefixer-rails-5.2.0.1 lib/autoprefixer-rails/sprockets.rb
autoprefixer-rails-5.2.0 lib/autoprefixer-rails/sprockets.rb