How to get multiple output files with rails resource pipeline?

I am developing a rails application that handles a public zone (today, static pages) and a private space with authentication, etc. Both were independently developed. The former has a manual style, the latter uses twitter bootstrap.

In production, the rails compile my assets into a single file, and some styles conflict, resulting in some Twitter Bootstrap elements in the public zone ... Not what I want.

Is there a way to configure an asset pipeline, so when it compiles there are two ways out? classic application.css and front.css?

+4
source share
1 answer

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

application.css should contain all the public CSS files, and you will need to remove the require_tree directive, as this is what includes what you don't want.

The second admin.css manifest admin.css will contain what you want for the private party.

You can then reference these files in layouts using the Rails helpers.

You will need to add admin.css (and .js, if any) to the precompilation array for this to work correctly during production:

  config.assets.precompile + = ['admin.js', 'admin.css']
+7
source

Source: https://habr.com/ru/post/1384124/


All Articles