You can get multiple top-level CSS files by creating a Sprocket file for each. For example, suppose you want desktop.css consist of reset.css , common.css and ie.css and mobile.css , consisting of common.css and ios.css . You will have the following files:
app/assets/stylesheets/desktop.cssapp/assets/stylesheets/mobile.cssapp/assets/stylesheets/reset.cssapp/assets/stylesheets/common.cssapp/assets/stylesheets/ie.cssapp/assets/stylesheets/ios.css
In desktop.css you will have the following:
/* *= require reset.css *= require common.css *= require ie.css */
In mobile.css you will have the following:
/* *= require common.css *= require ios.css */
Then, in app/views/layouts/desktop.html.erb , you would do
<%= stylesheet_link_tag :desktop, :debug => Rails.env.development? %>
and similarly for mobile.html.erb .
Finally, you need to set the list of precompiled assets in config/environments/production.rb :
config.assets.precompile = %w( desktop.css mobile.css )
James A. Rosen
source share