How to inline compressed CSS in Rails with assets pipeline
- by haimg
I'm trying to inline CSS into my layout. I'm currently using
= Rails.application.assets.find_asset('embedded.css').body.html_safe
However, the CSS returned is not compressed. I verified what .digest_path asset file exists, and is properly compressed.
I can, of course, write a helper that will check if current on-disk compressed asset file exists for a given asset, and use it. However, I think find_asset actually compiles a CSS asset each time it is called -- not good in production. I hope a cleaner solution exists for this issue.