What is the best way to minimize CSS output from LESS?

Is it possible to minimize compiled automatic CSS with LESS? Every time I have to manually compress it when I change something.

I am using less.js to compile LESS.

Thanks.

+6
source share
3 answers

If you use the Less command line compiler, you can pass the -x option to output reduced CSS.

 $ lessc styles.less -x 

This is described in Less doc :

To output minimized CSS, simply pass the -x option. If you would like to be more involved, Clean CSS is also available with --clean-css .

To view all command line options, run lessc with no options.

+5
source

$ lessc styles.less -x The compression command is deprecated.

you will need to use this command $ lessc -clean-css style.less style.min.css

before using the command above you should install less-plugin-clean-css using the following command

 $ npm install less-plugin-clean-css -g 
+3
source

According to github README.md, to minimize this you should use this command:

 lessc file.less --clean-css="--s1 --advanced --compatibility=ie8" 
0
source

Source: https://habr.com/ru/post/974578/


All Articles