Sha256: d44d3ea6c6aa1220bd7e0202a7898bd1e34a736b42568374c459ab2c13d74430

Contents?: true

Size: 773 Bytes

Versions: 7

Compression:

Stored size: 773 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)
      root   = Pathname.new(context.root_path)
      input  = context.pathname.relative_path_from(root).to_s
      output = input.chomp(File.extname(input)) + '.css'

      @processor.process(css, opts.merge(from: input, to: output)).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

7 entries across 7 versions & 1 rubygems

Version Path
autoprefixer-rails-4.0.0.1 lib/autoprefixer-rails/sprockets.rb
autoprefixer-rails-4.0.0 lib/autoprefixer-rails/sprockets.rb
autoprefixer-rails-3.1.2.20141016 lib/autoprefixer-rails/sprockets.rb
autoprefixer-rails-3.1.1.20141001 lib/autoprefixer-rails/sprockets.rb
autoprefixer-rails-3.1.0.20140911 lib/autoprefixer-rails/sprockets.rb
autoprefixer-rails-3.0.1.20140826 lib/autoprefixer-rails/sprockets.rb
autoprefixer-rails-3.0.0.20140821 lib/autoprefixer-rails/sprockets.rb