class AutoprefixerRails::Sprockets

Register autoprefixer postprocessor in Sprockets and fix common issues

Public Class Methods

new(processor) click to toggle source
# File lib/autoprefixer-rails/sprockets.rb, line 6
def initialize(processor)
  @processor = processor
end

Public Instance Methods

install(assets, opts = {}) click to toggle source

Register postprocessor in Sprockets depend on issues with other gems

# File lib/autoprefixer-rails/sprockets.rb, line 24
def install(assets, opts = {})
  assets.register_postprocessor('text/css', :autoprefixer) do |context, css|
    process(context, css, opts)
  end
end
process(context, css, opts) click to toggle source

Add prefixes for `css`

# File lib/autoprefixer-rails/sprockets.rb, line 11
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