In the Rails docs for the asset pipeline, it states:
The default behavior in Rails 3.1 and onward is to concatenate all files into one master file each for JS and CSS. However, you can separate files or groups of files if required (see below)
How exactly do you separate the files into groups as indicated? For example, if I've got an application that also has an admin area, I'd like to create three compiled files:
shared.css (both front- and back-end use this)
application.css (front-end only)
admin.css (back-end only)
The default combines all my files into application.css.
You will need to create a manifest for each area. For example:
admin.css:
/*
*= require shared/nomalize
*= require shared/960.css
*= require admin/base
*= require admin/tables
*/
shared.css:
/*
*= require shared/nomalize
*= require shared/960.css
*= require public/base
*= require public/branding
*/
You are free to make folders to hold shared, public and admin CSS and require these as required. You will have to remove require_tree directives from any manifests
Reference these in your layouts:
<%= stylesheet_link_tag "application" %>
<%= stylesheet_link_tag "admin" %>
and add the addittional manifests to the precompile array:
config.assets.precompile += ['admin.js', 'admin.css']
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With