LESS css compiler help in terminal

2019-07-20 12:31发布

问题:

Im using Ubuntu 13.04 (Linux) I have installed node, and npm. With npm I downloaded less via terminal.

Im using this on my simple HTML/CSS project. pure frontend. its not a Ruby or nodejs project.

And when I do

lessc styles.less styles.css -x -w

in terminal, it compiles and compresses the code, but doesn't watch the file for changes, since Im expecting LESS to auto compile and refresh the page automatically. So, if I do any changes in my styles.less, every-time I have to go to terminal and enter the command to compile the less css.

Also, the compiler does NOT even show any compile errors even if I add anything on purpose, but in that case it doesn't compiles.

Please guide me on how to achieve the above. This is my first day with LESS CSS.

回答1:

If you type lessc help you will see that there is no argument -w or --watch. What you can do is to use a build system like GruntJS with an extension like grunt-contrib-watch and have that monitor your less files and build the css on change.



回答2:

I did this with help of @Oil on ubuntu forums.

In terminal, 1. install sudo apt-get install inotify-tools

  1. then simply CD to the css folder. and run below lines together:

    while inotifywait -r styles.less; do lessc -x styles.less styles.css; done