less / more

less on rails — the official LESS plugin for Ruby on Rails
http://lesscss.org
MIT License
226 stars 41 forks source link

Heroku support #4

Closed augustl closed 15 years ago

augustl commented 15 years ago

Suggesting that we do a major rewrite of the functionality to achieve this. First, how heroku has to be supported.

Heroku doesn't allow write access to the file system. The generated CSS has to be served through controllers. If you set the correct headers, heroku will use varnish to cache the output so that it isn't served dynamically on every request. This is what http://github.com/augustl/less_for_rails_with_cache_control does.

In order to avoid duplicate code, I'm thinking that we should use this controller when we aren't on heroku as well, and use Rails' page caching functionality to create the files. The page cache for the stylesheets controller will be wiped in a before_filter to the application controller in development mode, and left as-is in production mode.

This way, we'll end up with a lot less code, because we'll avoid doing things twice in different ways.

logandk commented 15 years ago

Sounds good, I like the way it's done in less_for_rails_with_cache_control. How about making Rails' page caching default and adding an configuration option for switching to Cache-Control headers?

augustl commented 15 years ago

Yep, that's what http://github.com/cloudhead/more/blob/master/lib/more.rb#L40 is there for. Less::More.page_cache = false. It'll be false by default when deploying on heroku, so that it works out of the box there.

I'll get started with this rewrite-ish today! Shouldn't take too long.

augustl commented 15 years ago

http://figureoutwhen.com/ is deployed on heroku, and uses this plugin. So it seems like everything is working. The varnish headers are set and so on. Yay!

logandk commented 15 years ago

Great work! Looks very clean :)

stevenhaddox commented 14 years ago

@augustl is this plugin still around? I'm not seeing it and I can't find the easy solution to make heroku and Less / More happy together...

augustl commented 14 years ago

The plugin is still around - you're commenting on it's issue tracker. I probably misunderstood your question? :)

stevenhaddox commented 14 years ago

My apologies, I was exhausted when I posted that. I was referencing the plugin that made heroku support work: http://github.com/augustl/less_for_rails_with_cache_control (which I can't seem to find).

Perhaps I misunderstood your comment where you said, "http://figureoutwhen.com/ is deployed on heroku, and uses this plugin." (I thought you'd meant the less_for_rails_with_cache_control and not "more"). Btw, I love more... just struggling to get it working with heroku on a project.

Currently I have to recompile the CSS every commit along with this in the application_controller: skip_before_filter :generate_css_from_less if Rails.env.production?

Any tips / suggestions are greatly appreciated as I'd love to not have to commit my CSS files when Less should handle them just fine ;)