Precompile assets for a rails engine

Posted by Peter Ehrlich on Stack Overflow See other posts from Stack Overflow or by Peter Ehrlich
Published on 2012-04-01T17:26:10Z Indexed on 2012/04/01 17:29 UTC
Read the original article Hit count: 251

In a standard app, I have this line in my production.rb, which creates endpoints for non-default precompiled assets:

config.assets.precompile += %w( mobile.css )

My rails engine is a standard Sinatra app. It has its own assets.

When on development, these assets are served fine, presumably the web requests are handled by rails and sprockets. On production I'm getting 404s on the assets, and think I have to manually tell sprockets to provide the files. How can this be done without tightly linking?

It isin't evident how to set up env-specific initializers for engines. Is this done? Not only, for example, is config/development.rb within the engine not loaded, but there's no way to get the application class itself without knowing its name, in order to modify configuration.

And even if there was, it seems that having any engine able to reconfigure the main app would be very bad idea.

So maybe its better to let assets handling be done by sinatra itself? Or another instance of sprockets for the engine? How do other engines handle this?

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about asset-pipeline