Skip to content

Instantly share code, notes, and snippets.

@denmarkin
Created March 29, 2011 19:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save denmarkin/893066 to your computer and use it in GitHub Desktop.
Save denmarkin/893066 to your computer and use it in GitHub Desktop.
Rails 3 initializer for Heroku/SASS setup
# 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