Using Sass without Ruby

Posted in: Design, Development

As Liam recently pointed out, we have started using Sass to manage our stylesheets.  This is great, and I've become a big fan of Sass with its variables, nested rules, mixins, etc.

However, we had an issue with using Sass because we don't have Ruby support on our production servers and most of the common Sass compilers rely on Ruby.

Although we could happily use Compass for development, we couldn't use it for production.  We had to find an alternative.

We turned to our standard server-side language and looked for a Sass complier written in PHP.  We found 2 that seemed promising:

  1. PHPSass
  2. scssphp

Initial testing with PHPSass gave us problems with @import statements and CSS that was invalid, so we moved on to scssphp.

scssphp script
Compiling SASS with PHP

The key for us was finding something that would compile the Sass for the Foundation 4 framework and produce output as close to the Compass-compiled CSS as possible.  At first there were some significant issues, but looking through the github repos showed that most of the issues had been fixed in later versions.

We retrieved the latest versions of Foundation and scssphp and this fixed all but one issue which was a double quoting problem.  Although we could override this ourselves, we wanted the underlying issue in Foundation to be fixed so we submitted a pull request which was subsequently merged in.

We could now slot the Sass compilation straight into our workflow for publishing to our production sites.  With a bit of scripting to run the scssphp, our Bamboo build server can compile the Sass and deploy the updated CSS to the frontline web server with a simple click of the mouse.

Posted in: Design, Development