Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vendor CSS stylesheets in Rails 3.1 and the asset pipeline

I use Twitter Bootstrap (not that that matters but it's a third party CSS file). Because it's a third party CSS "library" it should go in /vendor/assets/stylesheets. So far so good.

Now, I would like to concatenate all CSS in one application.css in production using the Rails 3.1(.1) asset pipeline and that's where I get stuck.

When I run rake assets:precompile it works as advertised. The Rake task creates a few application.css files in the public/assets folder with the digest and all. Problem is this file only contains the CSS from my CSS files in /app/assets/stylesheets and completely ignores the one in my vendor assets folder.

Does anyone know what I miss here and how I can tell Rails to concatenate the vendor stylesheet together with the app one(s)? Also, is it enough to only include:

<%= stylesheet_link_tag "application" %>

in the view (as I expect everything to be in one file in the end) or should I include every single CSS file?

like image 794
Cimm Avatar asked Oct 09 '11 19:10

Cimm


People also ask

How do you Precompile rails assets?

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 is asset pipeline in rails?

1 What is the Asset Pipeline? The asset pipeline provides a framework to concatenate and minify or compress JavaScript and CSS assets. It also adds the ability to write these assets in other languages and pre-processors such as CoffeeScript, Sass, and ERB.

Where do CSS files go in rails?

Place stylesheets in app/assets/stylesheets/ if they are specific to your application. You can also put them at vendor/assets/stylesheets/ if they are external (say if they are stylesheets for a javascript plugin.) After that, you will include stylesheets using the app/assets/stylesheets/application.

What does rake assets Clean do?

Two cleanup tasks: rake assets:clean is now a safe cleanup that only removes older assets that are no longer used, while rake assets:clobber nukes the entire public/assets directory. The clean task allows for rolling deploys that may still be linking to an old asset while the new assets are being built.


1 Answers

I have exactly your configuration, it works fine. Are you sure you're requiring bootstrap in your application.css? Like:

/*
*= require bootstrap
*= require_self
*/
like image 74
lucapette Avatar answered Sep 20 '22 18:09

lucapette