How to keep duplicate properties in compiled CSS file when use LESS?

两盒软妹~` 提交于 2019-11-26 23:39:54

问题


LESS code

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

CSS expected

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

but less.js remove the first background-size property in compiled CSS file.


回答1:


AS already pointed out by @seven-phases-max clean-css removes these properties.

Notice that the --advanced has been set by default. You should use the --skip-advanced option to prevent your double properties from being removed.

According to https://github.com/less/less-plugin-clean-css the advanced option has been set to false by default.

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}

Alternatively you could run lessc -x foo.less which also outputs:

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


来源:https://stackoverflow.com/questions/27544448/how-to-keep-duplicate-properties-in-compiled-css-file-when-use-less

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!