Question

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?

Was it helpful?

Solution

Yes, there is. You need to have two manifest files. I would call the public one application.css and the private one admin.css as this is a common Rails convention.

The application.css should 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:

config.assets.precompile += ['admin.js', 'admin.css']
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top