What is the best method for storing SASS generated CSS in your application and source control? What is the best method for storing SASS generated CSS in your application and source control? ruby-on-rails ruby-on-rails

What is the best method for storing SASS generated CSS in your application and source control?


The compass framework recommends putting your sass stylesheets under app/stylesheets and your compiled css in public/stylesheets/compiled.

You can configure this by adding the following code to your environment.rb:

Sass::Plugin.options[:template_location] = {  "#{RAILS_ROOT}/app/stylesheets" => "#{RAILS_ROOT}/public/stylesheets/compiled"}

If you use the compass framework, it sets up this configuration for you when you install it.


I always version all stylesheets in "public/stylesheets/sass/*.sass" and set up an exclude filter for compiled ones:

/public/stylesheets/*.css


Honestly, I like having my compiled SASS stylesheets in version control. They're small, only change when your .sass files change, and having them deploy with the rest of your app means the SASS compiler doesn't ever need to fire in production.

The other advantage (albeit a small one) is that if you're not using page caching, your rails process doesn't need to have write access to your public_html directory. So there's one fewer way an exploit of your server can be evil.