Languages
[Edit]
EN

LESS / CSS - minify css file

8 points
Created by:
Sujay
512

In this short article, we want to show how to compress *.css files with lessc command.

Quick solution:

lessc input_file.css --clean-css="--s1 --advanced" > output_file.min.css

 

Note: read the below description to know how to install lessc command.

Screenshot:

css compression result with lessc command (file was compressed about 65%)
css compression result with lessc command (file was compressed about 65%)

lessc installation instruction

To install lessc it is necessary to do few steps:

  1. be sure that NodeJS is installed (installation instruction for Windows is available here),
     
  2. install less using:
    npm install -g less
     
  3. install lessc using:
    npm install -g less-plugin-clean-css
    Example output:
    + less-plugin-clean-css@1.5.1
    added 6 packages from 39 contributors in 1.858s
     
  4. now we can use lessc command (go back to Quick solution).

 

See also

  1. SCSS - compile and minify to css file

References

  1. less-plugin-clean-css - npm 
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.

Web resources compression / minify (JS, CSS)

Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join