Precompile assets for a rails engine
- by Peter Ehrlich
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?