I’m developing a rails app which handles a public area (as of today, static pages), and a private space with authentification, etc. Both of those were developed independently. The first has hand-made style, the latter uses twitter bootstrap.
In production, rails compile my assets into one file, and some styles are conflicting, resulting in the public area having some elements of Twitter Bootstrap… Not what I want.
Is there a way to configure the asset pipeline so when it compiles, there is two output ? the classic application.css, and the front.css?
Yes, there is. You need to have two manifest files. I would call the public one
application.cssand the private oneadmin.cssas this is a common Rails convention.The
application.cssshould require all the public CSS files, and you will need to remove the require_tree directive as this is what is including things you don’t want.The second manifest file,
admin.css, will include the things you want for the private side.You can then reference these files in the layouts using the Rails helpers.
You will need to add the admin.css (and .js if there is one) to the precompile array for this to work correctly in production: