How to save duplicate properties in compiled CSS file when using LESS?

LESS code

.foo {
  background-size: 200px; //for old browsers
  background-size: cover;
}

CSS expected

.foo {
  background-size: 200px; 
  background-size: cover;
}

but less.js removes the first property background-sizein the compiled CSS file.

+1
source share
1 answer

AS already specified by @ seven-phase-max clean-cssremoves these properties.

Please note that the parameter is --advancedset by default. You must use the parameter --skip-advancedto prevent duplicate properties from being removed.

In accordance with https://github.com/less/less-plugin-clean-css option advancedby default is set to false.

lessc foo.less outputs:

.foo {
  background-size: 200px;
  background-size: cover;
}

lessc --clean-css foo.less outputs:

.foo{background-size:200px;background-size:cover}

lessc --clean-css="advanced" foo.less outputs:

 .foo{background-size:cover}

lessc -x foo.less, :

.foo{background-size:200px;background-size:cover}
+1

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


All Articles