Extending Sprockets

96 Views Asked by At

I want to extend sprockets, and I think I want to do post-processing.

When in development, after application.css is created, I want to use css-flip https://github.com/twitter/css-flip to make a rtl copy of application.css, eg application.rtl.css bidi support.

Right now, I'm just trying to get something working.

I created config/initializers/sprockets.rb

require "hello_world_processor"

Sprockets.register_preprocessor('application/javascript', HelloWorldProcessor.new)

Then lib/hello_world_processor.rb

class HelloWorldProcessor
  def call(input)
    puts "hello world"
    return { data: input[:data] + "\n'hello world'" }
  end
end

I was hoping to at least see a "hello world" in the server logs, but no luck.

Anything jumping out to you as totally wrong?

0

There are 0 best solutions below