Skip to content

Instantly share code, notes, and snippets.

@kaplas
Last active August 29, 2015 14:00
Show Gist options
  • Save kaplas/11248521 to your computer and use it in GitHub Desktop.
Save kaplas/11248521 to your computer and use it in GitHub Desktop.
Observations about replacing Compass with node-sass (using libsass) + autoprefixer

Observations about replacing Compass with node-sass (using libsass) + autoprefixer

  • Node-sass is quite easy to use, but a custom grunt task will always require more custom boilerplate code than ready made compass grunt plugins (didn't try grunt-sass because we needed to use autoprefixer as well)
  • Absolute image paths don't work too well with node-sass. Ie. URL 'images/foo.bar', with node-sass imagePath '' will get transformed into '/images/foo.bar', which will of course break stuff. I had to make a dirty hack to overcome that one.
  • Image URL cache busters are not yet implemented in libsass
  • I couldn't get CSS source maps to work, but there was quite a many variables in our setup (eg. a Vagrant VM), so I'm not sure where the problem actually was
  • Autoprefixer was super easy to use, and worked out of box
  • We weren't using as much Compass mixins as I though we would be, so replacing those with vanilla CSS didn't take too long

Plus some extras:

  • Had to write my own globbing script to replace sass-globbing gem
  • I wrote all this custom code using promises (via bluebird), and it was pure joy

Compilation time

Update 29th of April 2014: It seems that Grunt is messing up my measurements heavily. I will try to make exact measurements based on the reported times of the actual scripts in the near future.

  • Mac host with Vagrant + VirtualBox + Ubuntu + NFS guest
    • compass + sass-globbing: 0.9 sec
    • my sass-glob script: 0.28 sec
    • libsass + autoprefixer: 0.20 sec
  • Windows host with Vagrant + VirtualBox + Ubuntu + VB shared folders guest
    • TBD next week, but I have really high hopes for this one, as the current compass setup takes something between 15 and 40 secs. I know, it's insane.

Was it worth it?

We've had so much troubles with all Ruby dependencies, that even if the Windows performance wouldn't improve as much as I hope it would be, I'm very glad I've done this. If the Windows performance will get noticeably better, this task was golden.

@F21
Copy link

F21 commented May 28, 2014

I think the performance issues with windows is due to VB shared folders. Vagrant 1.5+ now supports SMB and rsync for windows, so you could try them to see if performance improves.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment