Skip to content

Instantly share code, notes, and snippets.

@mdub
Created December 15, 2010 11:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mdub/741890 to your computer and use it in GitHub Desktop.
Save mdub/741890 to your computer and use it in GitHub Desktop.
serve *.sass using Rack::File
# app/metal/sass_stylesheets.rb
#
# This Rails metal keeps Sass stylesheets up-to-date, and serves them using Rack.
#
# Unlike the default Sass/Rails integration, this happily supports a
# Sass::Plugin.options[:css_location] outside the Rails.public_path.
#
class SassStylesheets
class << self
def call(env)
Sass::Plugin.check_for_updates
sass_file_server.call(env)
end
private
def sass_file_server
stylesheets_dir = Sass::Plugin.options[:css_location]
@sass_file_server ||= ::Rack::File.new(File.dirname(stylesheets_dir))
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment