Make Slate/Middleman recompile CSS faster

Slate is a great code documentation setup based on Middleman. I’ve been playing with it a bit and like it a lot since it’s based on Padrino and very easily extended.

However, I had this problem that every page reload would take roughly five seconds. It turned out the problem is the CSS compilation happening every time I reload.

Screenshot_2018-01-25_09-34-30

Since I’m running Ubuntu Linux, I figured I need to use the therubyracer gem.

source 'https://rubygems.org'

# Middleman
gem 'middleman', '~>4.2.1'
gem 'middleman-syntax', '~> 3.0.0'
gem 'middleman-autoprefixer', '~> 2.7.0'
gem "middleman-sprockets", "~> 4.1.0"
gem 'rouge', '~> 2.0.5'
gem 'redcarpet', '~> 3.4.0'
gem 'nokogiri'#, '~> 1.6.8'

gem "sassc"
gem 'sprockets', github: 'rails/sprockets'

gem "therubyracer"

Suddenly, page reloading was 1.5 seconds.

I then configured Sass to use sassc and grabbed Sprockets from their repository to get a 4.0.0.beta version, as recommended in several issue discussions. That sped up server startup by around 1 second.

Leave a comment