Most of my newer projects tend to be smaller projects where I don’t want to have the massive overhead that Rails brings with it, or what I’m trying to build doesn’t necessarily fit the Rails use case.
To do this, I’m using the
Sass::Plugin::Rack functionality, and
First, add them both to your Gemfile:
source :rubygems gem 'sinatra' gem 'sass' gem 'rack-coffee'
Then add the hooks into
So now you can put your stylesheets into the
and they will be automatically compiled to CSS when changes are made.
For an example app with a directory structure like this:
layout.haml you might have something like this:
There are also a few alternatives, and
sprockets can be rigged to work with
Sinatra apps, but this is the solution that works for me. It also helps to
supply a long cache lifetime for stylesheets and scripts if you’re using this