Reputation: 18871
I am using Ruby on Rails 3.0.10 and I would like to auto-build and load different CSS stylesheet files depending on if I am running my application in the development
or in the production
mode.
I would like to auto-"minimize" CSS files for performance reasons and to load those related "minimized" files because I do not want to show to the "public audience" the content of my comments present in my CSS file (note: users can access theme, for example, by using the FireBug plugin for the Mozilla Firefox browser). I would like to do that also for javascript files.
How can I do that?
P.S.: I am planning to switch to the Ruby on Rails v3.1...
Upvotes: 3
Views: 709
Reputation: 16834
For Rails 3.0 there are many plugins to minify your css and javascript.
I use smurf
.
gem "smurf"
Part of the process of minification is that it removes comments.
In Rails 3.1 production will uglify
your javascript, so comments should be removed by default.
But if you insist on using a different stylesheet, take a look at the other answer.
Upvotes: 1
Reputation: 13848
In your layout you probably have something like:
<%= stylesheet_link_tag "production.css" %>
Just add another stylesheet there but wrap it in a conditional that checks the rails environment.
<%= stylesheet_link_tag "development.css" if Rails.env.production? %>
Upvotes: 7