Created
March 29, 2011 19:36
-
-
Save denmarkin/893066 to your computer and use it in GitHub Desktop.
Rails 3 initializer for Heroku/SASS setup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# see http://forrst.com/posts/Setting_up_SASS_on_Heroku-4dZ | |
# You can put this in config/initializers/sass.rb | |
# Setup directory in tmp/ to dump the generated css into | |
require "fileutils" | |
FileUtils.mkdir_p(Rails.root.join("tmp", "stylesheets", "generated")) | |
# Tell SASS to use the .sass files in public/stylesheets/sass and | |
# output the css to tmp/stylesheets/generated | |
Sass::Plugin.options[:template_location] = { | |
'public/stylesheets/sass' => 'tmp/stylesheets' | |
} | |
# Use Rack::Static to point all requests beginning | |
# with /stylesheets to the tmp/ dir | |
# see http://devcenter.heroku.com/articles/using-compass | |
# It's okay for developer to have CSS generated inside tmp/ | |
Rails.configuration.middleware.delete('Sass::Plugin::Rack') | |
Rails.configuration.middleware.insert_before('Rack::Sendfile', 'Sass::Plugin::Rack') | |
Rails.configuration.middleware.insert_before('Rack::Sendfile', 'Rack::Static', | |
:urls => ['/stylesheets'], | |
:root => "#{Rails.root}/tmp") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment