Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to speed up sass-compilation?

When compiling sass I tend to have very long compilation times (up to 9 seconds on the current mid-scale project) on my otherwise very fast laptop with an ssd. I'm using sass via grunt-contrib-sass ass a grunt task, but the compilation times don't differ much when running sass directly from the command line. Libsass on the other hand just needs around 100ms for the same project, but it doesn't support several features I need. So I would like to know what possibilities I have to speed up the compilation process?

Splitting up files helps of course, but are there other ways to do so with less side-effects?

Edit: In addition I would be also glad for an explanation how libsass could so much faster than ruby-sass. Somehow I highly doubt that it is just because ruby is so much slower than C/C++. Or am I wrong here?

Edit2: While I'm using Ubuntu, the same project is compiled in 2 seconds on a macbook pro, which is supposed to be slower, when it comes to the hardware, so this might be related to linux somehow.

like image 511
hugo der hungrige Avatar asked Jun 03 '14 22:06

hugo der hungrige


1 Answers

What I've found out so far:

  • changing ruby-version: I had ruby 2.1.2 and sass 3.3.8 installed (current latest stables). After uninstalling all the previous (unused?) sass versions I had a speed increase of 1 second. Installing ruby 1.9.3 and then 2.0.0 everything compiles in around 2 seconds now (for both ruby versions). :) I'm still open to further suggestions though.

Only grunt related:

  • update-autoprefixer: If you're using grunt-autoprefixer then I strongly suggest you to update it to the newest version (1.0.0 atm). I had a spead increase from 13 to 4 seconds in one of my projects. The update also fixes the broken source maps issue.

  • use jit-grunt instead of load-grunt-tasks: If you're using grunt-load-tasks consider using jit grunt instead. There is a significant speed increse.

like image 173
hugo der hungrige Avatar answered Oct 15 '22 05:10

hugo der hungrige