Read more

Speed up response time in development after a Sass change

Arne Hartherz
March 14, 2011Software engineer at makandra GmbH

When working with large Sass Show archive.org snapshot files you will notice that the first request after a change to a Sass file takes quite some time. This is because the CSS files are being generated from the Sass files the moment the application answers your request (Sass looks at the files and recompiles if the timestamp changed); it takes even longer when you build sprites with the Lemonade gem.

Illustration online protection

Rails Long Term Support

Rails LTS provides security patches for old versions of Ruby on Rails (2.3, 3.2, 4.2 and 5.2)

  • Prevents you from data breaches and liability risks
  • Upgrade at your own pace
  • Works with modern Rubies
Read more Show archive.org snapshot

To avoid this, have Sass watch the files for changes and compile them into CSS files immediately. The files will be created while you are still on something else, allowing the first request to be served without a Sass compile.

  • For plain Sass (no lemonade) run the following from your project directory:
    sass --watch public/stylesheets/sass:public/stylesheets
    That keeps an eye on all .sass files inside public/stylesheets/sass (and subdirectories) and compiles them into their corresponding CSS files inside public/stylesheets.

  • When your project uses Lemonade just call:
    compass watch

When using the latter you do not need to sass --watch explicitly as compass does that already.

Posted by Arne Hartherz to makandra dev (2011-03-14 17:26)