Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the best way to split css files for IE through assets:precompile assets pipeline

I am using the CssSplitter module by CristianPeters. And I am hoping to have the split occur during the assets:precompile task and the only way I have been successful so far is to patch the Sprockets::StaticCompiler. Hoping there is a better way to do it.

I appreciate any advice

like image 872
Baldur Avatar asked May 15 '12 14:05

Baldur


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?

RAILS_ENV=production tells Rails to compile the production version of the assets. assets:precompile is a Rails provided rake task that has instructions for compiling the assets.


2 Answers

When confronted to this problem, I just split my manifest in 2 :

  • having 1 for base (reset, twitter bootstrap, …) and
  • the other for application specific CSS
like image 195
tal Avatar answered Oct 17 '22 09:10

tal


If you are writing stylesheets specifically for the IEs, it's best not to concatenate them all together. Therefore, I would have a main manifest file, where I would load all my general stylesheet files together, and 1/2/3 manifest(s) for the IE(s) using the conditional comments (http://www.quirksmode.org/css/condcom.html) :

<%= stylesheet_link_tag :application %> // main manifest
<!--[if IE 6]>
<%= stylesheet_link_tag :ie6 %> // ie6 manifest
<![endif]-->
<!--[if IE 7]> ....

in this manner I would be assured that the css loading performance wouldn't be hurt in the non-IE browsers and that my IE-specific stylesheets would not be loaded for the various versions in which they are anyways not supposed to be loaded (IE6 corrections in IE7, p.ex.).

like image 44
ChuckE Avatar answered Oct 17 '22 08:10

ChuckE