Heroku Sass

by Oren - Aug 18, 2009

No, we’re not talking back. Instead, we’re excited to announce that you can now use Sass on Heroku.

We’re big believers in elegance here, and Sass is a way to bring elegance to your CSS and page layout. Due to our read-only filesystem Sass hasn’t worked well on Heroku. Thanks to the efforts of one of our awesome engineers, there’s now a beta plugin available that enables you to use Sass & Heroku frictionlessly.

To use the plugin, install Sass as you normally would – include the HAML gem in your gem manifest. Then, script/plugin install the sass_on_heroku plugin:

$ script/plugin install git://github.com/heroku/sass_on_heroku.git

The plugin compiles Sass files to tmp/ and serves them from there. We’re able to do this magic by adding Rack middleware on top of your Rails app that quickly detects requests for Sass CSS files, and serve them with proper caching headers.

The plugin is in beta. We’d love to hear from you if you run into any issues.

You are commenting as a Guest. Optional: Login below.

Comments for this page are closed.

Showing 13 comments

Sort by   Subscribe by email Subscribe by RSS
  • Stephan 3 months ago
    Works great so far…

    Keep in mind that if you are using an environment other than production you have to enable the middleware by yourself.
  • danieldrehmer 6 months ago
    Why not simply recommending Compass, which compiles CSS from Sass in realtime in the development environment?

    Then simply commit without excluding the 'public/stylesheets/compiled' path and you're safe!

    I think it's the way to go, no additional plugins in production, which is always recommended.
  • You'd end up committing css files with extra comments.

    Above plugin plays along well with Compass.
  • Sass has this same behavior with or without Compass. But your solution would have us commit generated files to the repository, which is not a good idea. Personally, I'd rather just have Sass write to tmp.
  • Great, will be using this for sure.
  • not working for me :-(

    /disk1/home/slugs/45406_b69403c_377f/mnt/vendor/plugins/sass_on_heroku/init.rb:2:in `evaluate_init_rb': undefined method `middleware' for ActionController::Dispatcher:Class (NoMethodError)
  • humm, which Rails version?
  • Great work, guys. I've wanted this for a while. I handled the issue with a pre-commit hook that wrote out all the CSS files beforehand, but this new solution is much more elegant. Thanks!
  • Thanks.

    I'm sure a lot of people want to generate a .js or .css file (aka less routes, sass)

    I generate content to tmp/generated/
    cd public ; ln -s ../tmp/generated . ; cd ..
    git add public/generated

    nothing dynamic 100% nginx
  • I guess this is a bit nicer than the hack I was using before. Basically I had an if statement check if it was running on Heroku, then it wouldn't compile SASS. Since all the SASS got compiled to CSS on my development machine, that has been enough.

    It seems weird to go from my 2-line solution to a 75-line solution, but I guess this version will be well maintained. Using it means I won't have to worry about keeping up with changes to Heroku or Sass.
  • seanschofield 7 months ago
    Very cool. That's a big step towards using something like Spree on Heroku. The only problem left to solve is stylesheet and javascript caching. Would be cool if that could be addressed as well.
  • I've been using SASS and Less both for quite some time using a plugin I wrote:
  • This sounds useful. How well has it been tested so far?