23 December 2014

Building Less (CSS) in Sublime Text 3

A quick hack.

Less is great. Having to manually compile it isn’t.

In lieu of using something like Grunt (which is probably a much better long-term solution), I came up with a quick Sublime Text Build System to just stick in my project file and use. Triggering it from within a .less file passes that file to lessc and saves the result as a .css file in the same directory as the original.

Here it is:

        {
            "shell_cmd": "lessc \"$file\" > \"${file/\\.less/\\.css/}\"",
            "selector": "source.less",
            "name": "LESS CSS"
        }

Sticking that in the build_systems array in .sublime-project causes it to show up under Tools -> Build System, and choosing Automatic should cause it to only trigger from within a .less file.

However:

I should just use Grunt. Or something.