Automatic LESS compilation using mod_rewrite and lessphp
less than 1 minute read
I have been using LESS (and before SCSS) and I enjoy it, but I have to admit that I was spoiled by Symfony, Twig and Assetic that compile them automatically and I am really not looking forward to compile all my assets. I could use an application that watches a directory and compiles them on the fly, but there’s none that works on all OS and you still have to fire them up and configure them each time you start a project or reboot your computer.
Using lessphp, I made a simple script that will compile your LESS files, do some caching, gzip, etc.
It works by checking that a .css file exists. If not, it checks if the corresponding .less exists. If so, it fires up lessphp.
It is not perfect, but is worth using on simple projects.