Rails asset pipleline: compile multiple style sheets

Due to the specific setting, I would like to split the compiled style sheets in two files. This is because (part) of the CSS is required for a Java application that can parse CSS, but it is a bit erroneous and cannot handle some css- (hack) -syntax. Since I cannot change this Java application, I want to give it only the CSS that it needs, and I can make sure that it is correct.

So, as a rule, the asset pipeline would create only one file / assets / application - [..]. Css. This would also allow the generation of "/assets/custom-[...06.2012.css" based on the selection of the file I am making. This can still be precompiled.

Is there any way to do this? Although I understand that this is not an ideal setting.

+7
source share
1 answer

To indicate rails about additional files that you want to precompile, you can add them to config.assets.precompile .

 config.assets.precompile += ["other_application.css"] 

You only see application.css in your HTML, because the only file you include

 <%= stylesheet_link_tag "application" %> 

If you have custom.css.scss in your apps/assets/stylesheets directory, it will compile just like application.css .

For example, I may have

 - _common.css.scss - application.css.erb.scss - other_application.css.erb.scss 

in app/assets/stylesheets . At the top of the non-partial files I will put

 @import "common"; 

enable _common.css.scss . Now I can refer to either a stylesheet that is independent of each other in the layout.

 <%= stylesheet_link_tag "application" %> # or <%= stylesheet_link_tag "other_application" %> 
+12
source

All Articles