Less CSS compiler on Ubuntu: how to watch dependencies and compile on save
I just switched to Ubuntu (12.04) from Windows and I am struggling to find a solution to compile my .less files the same way I used using the "Winless" app. This beauty of the app is that I just need to keep track of the folder, save the main file ... and whatever was changed in the dependent files is compiled too.
I have googled for an hour and have seen many answers, but none of them are simple. And I am an ubuntu noob so everything is hard to understand. Closest less css for ubuntu (and compile automatically)? but it doesn't work as expected.
Can anyone point me in the right direction? I would like to have clear instructions on what I need to install and configure in order to get the same behavior for "WinLess".
source to share
If your fewer files are stored in subfolders less/
, you can track changes using inotifywait:
sudo apt-get install inotify-tools
Then create a file autocompile.sh
:
#! /bin/bash
while inotifywait -r less/*
do
lessc less/main.less > css/main.css # your compile command
done
Don't forget to give it execute rights:
chmod u+x autocompile.sh
And run it:
./autocompile.sh
Your compile command will run every time a file is changed in less/
.
source to share