Main Menu

Disabling Gantry’s LESS compiler

Seth Warburton · 25th of June, 2014

Gantry 4 has a built in LESS compiler that detects changes in a templates LESS files and recompiles the css accordingly, which I find problematic on several levels.

Firstly, this is a pretty intensive operation and, developing in MAMP, it caused PHP memory exhausted errors (I wouldn’t want this on a live site either, as I want all my servers resources available for serving pages, not watching LESS files). Secondly, I like to work with Codekit, because it is simply unbeatable.

I also found Gantry’s LESS compiler was ignoring basic syntax errors in the source files, which for me is a big deal. Codekit warns of errors and identifies the file they originate in, Gantry’s compiler doesn’t. Features like this are invaluable for professionals.

No problem, I thought, there must be a switch to disable the built in compiler. No. There isn’t. So, I quickly googled and found a pretty unhelpful response on the Rocket Theme Forums, along the lines of ‘Our compiler is the best implementation available anywhere, you can’t disable it.’.

So, I set about disabling it without their help and quickly found a likely-looking section of code, which I then commented out. Bingo! Now my MAMP server would load the site!! Moreover, I was now free to compile my LESS with my own settings, using my preferred (and vastly superior) compiler, CodeKit.

It’s unfortunate that there is no way to do this from within the template itself, as this change will not survive an update of Gantry’s Framework, but for anyone who wishes to follow the same path I chose you can disable Gantry’s LESS compiler in the file /libraries/gantry/core/gantry.class.php by simply commenting out lines 1088 - 1106;