Languages
[Edit]
EN

LESS / CSS - minify css file

8 points
Created by:
Sujay
332

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 --compatibility=ie8" > output_file.min.css

Note: read 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 example

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 with the following command:
    npm install -g less
  3. install lessc with the following command:
    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 

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