Compile LESS with Coda

Coda 2 doesn’t compile Less natively – as nice as it would be. There’s a plugin that does it, however at time of writing this, it doesn’t work for me (El Capitan PB2 / 2.5.11) and crashes the app.

When you’re working with shared hosting, where it’s nearly impossible to do anything to the server, it makes working with server-side Less kind of a pain. Here’s a way I found to automatically compile Less server-side after saving the file while using Coda 2.

In your remote site, have the following:

https://gist.github.com/davidsword/693c2e32f2a4a94ca05410a5631d7047

In lessc.inc.php copy/paste the contents from github.com/leafo/lessphp/

In lessc.php add:

https://gist.github.com/davidsword/c62651e91f85a978cbafce092a964364

Coda 2 has a handy default feature that refreshes your split preview window every time you save your split view file. We’ll take advantage of this making the preview window compile the newly saved /style.less file.

Simply split your /style.less page with a preview window set to the /lessc.php file on your server. Every time you save the .less file, Coda 2 will auto-execute the PHP Less compiler. Ta’da! Now hitting cmd+s on the keyboard uploads your Less file and compiles it.

Note: This isn’t the best way to compile, but it’s great if you’re working off of cheap shared hosting, or having to do something quick.