Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Asset Pipeline: excluding an admin.css file

I upgraded a Rails 3.0 app to Rails 3.1 which involved putting this

/* *= require_self *= require_tree . */ 

in the application.css file. However, there's an admin.css file that's now overriding the main app css file.

Is there a way to exclude the admin.css file from being included? In the admin section of the site I manually include the admin.css file but I need a way to exclude it from the user interface.

like image 891
Leahcim Avatar asked Feb 13 '12 04:02

Leahcim


People also ask

How do you Precompile an asset?

To compile your assets locally, run the assets:precompile task locally on your app. Make sure to use the production environment so that the production version of your assets are generated. A public/assets directory will be created. Inside this directory you'll find a manifest.

What does rake assets Precompile do?

rake assets:precompile. We use rake assets:precompile to precompile our assets before pushing code to production. This command precompiles assets and places them under the public/assets directory in our Rails application.

What is Require_self?

//= require_self. It loads the file itself, to define the order that the files are loaded.


1 Answers

You can use the stub sprockets' directive in your manifest like this :

/* *= require_self *= require_tree . *= stub admin */ 

This will exclude admin.css and also ALL css required in it !! So, if your admin.css's manifest seems like this :

/* *= require bootstrap *= require_self */ 

the bootstrap.css will also be excludes and no require could fixe this ! Take care of this ;)

like image 102
JoJoS Avatar answered Sep 19 '22 06:09

JoJoS