Class: AutoprefixerRails::Sprockets
- Inherits:
-
Object
- Object
- AutoprefixerRails::Sprockets
- Defined in:
- lib/autoprefixer-rails/sprockets.rb
Overview
Register autoprefixer postprocessor in Sprockets and fix common issues
Instance Method Summary collapse
-
#initialize(processor) ⇒ Sprockets
constructor
A new instance of Sprockets.
-
#install(assets) ⇒ Object
Register postprocessor in Sprockets depend on issues with other gems.
-
#process(context, css) ⇒ Object
Add prefixes for ‘css`.
Constructor Details
#initialize(processor) ⇒ Sprockets
Returns a new instance of Sprockets.
6 7 8 |
# File 'lib/autoprefixer-rails/sprockets.rb', line 6 def initialize(processor) @processor = processor end |
Instance Method Details
#install(assets) ⇒ Object
Register postprocessor in Sprockets depend on issues with other gems
24 25 26 27 28 |
# File 'lib/autoprefixer-rails/sprockets.rb', line 24 def install(assets) assets.register_postprocessor('text/css', :autoprefixer) do |context, css| process(context, css) end end |
#process(context, css) ⇒ Object
Add prefixes for ‘css`
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/autoprefixer-rails/sprockets.rb', line 11 def process(context, css) input = context.pathname.to_s output = input.chomp(File.extname(input)) + '.css' result = @processor.process(css, from: input, to: output) result.warnings.each do |warning| $stderr.puts "autoprefixer: #{ warning }" end result.css end |