How to enable sass caching? / Change sass options in middlemanapp

I am working on a project with complex scss consisting of multiple files and the refresh times in livereload take a long time.

It seems that in MIddleman caching is disabled for sass by default – I don’t see a .sass-cache folder anywhere. I believe that enabling it will speed up the compilation of scss dramatically. How can I re-enable this option?

Something like

sass_options = { cache: true }

I guess I am not sure how to access the sass options in Middlemanapp … how can I do this?

The Sass cache used to be enabled by default but was deliberately disabled in v3.3.0.

If you understand the consequences (I don’t) you can reenable it via Compass:

compass_config do |config|
  config.cache = true
end

I added this to the config file but unfortunately nothing changed. I also tried adding a cache directory manually to no avail.

compass_config do |config|
  config.cache_path      = "#{File.dirname(__FILE__)}/.sass-cache/"
  config.cache = true
end

Any idea how to approach this?

Hmm, I don’t understand why that doesn’t work. You might have to ping tdreyno for an explanation.

@tdreyno do you see a possible solution to this?

I think Sprockets is hijacking this and using it’s own cache instead. We are using an in-memory cache for Sprockets, it isn’t going to be on disk.

That all said, your problems probably aren’t in caching. Rather, Ruby Sass and Compass have some really gnarly file I/O problems. Lots of dependencies which cross reference each other or import large sets of imports (like @import "compass";) cause it to go into very nasty loops. I’ve seen 1+ minute build times all spent in file discovery :frowning:

For my projects, I personally avoid Compass and use autoprefixer instead. Hopefully LibSass in Ruby will stabilize soon and we could possibly switch to that as well.

Doesn’t middleman use compass to compile the files?

How can I remove the dependency?

I already use autoprefixer and could easily include sass-mixins if I needed more.

Added compass-mixins]1 to the css folder, removed compass from the Gemfile and now everything is a little snappier.