Minifiers不合并相同规则的选择器

huangapple go评论61阅读模式
英文:

Minifiers not merging selectors of same rules

问题

我正在使用sass来自定义Bootstrap。但是在分析被压缩的输出时,我看到有两个body {}选择器。

这是我的编译命令:

sass --load-path=./scss --style=compressed --no-source-map scss/bootstrap.scss ../../public_html/css/bootstrap.css

不满意的时候,我在互联网上测试了几个CSS压缩工具,以获得最佳压缩效果。以下是测试输入:

body{
    margin:0;
}

body {
    margin-top:60px;
}

大部分网站返回了这个压缩结果(与Sass返回的结果相同):

body{margin:0}body{margin-top:60px}

这不是我想要的。

但有一个特定网站 返回了这个压缩结果:

body{margin:60px 0 0}

哪个库可以为我提供这种令人难以置信的压缩能力(合并相同规则的选择器)?

英文:

I'm using sass to customize Bootstrap. But when analyzing the minified output, I see that there were two of body {} selectors.

Here is my compile command:

sass --load-path=./scss --style=compressed --no-source-map scss/bootstrap.scss ../../public_html/css/bootstrap.css

Not satisfied, I did a test several css minifiers in the internet in order to get the best minification. Here is the test input:

body{
    margin:0;
}

body {
    margin-top:60px;
}

Great part of websites returned this minification (which the same result returned by sass):

body{margin:0}body{margin-top:60px}

Which is not what I intended.

But one specific website returned this minification:

body{margin:60px 0 0}

Which library can grant me this incredible power of minification (Aka merging selectors of same rules)?

答案1

得分: 2

csso合并重复的选择器。

在这个在线压缩工具中试试它:

https://css.github.io/csso/csso.html

英文:

csso merges repeated selectors.

Give it a try in this live minifier:

https://css.github.io/csso/csso.html

huangapple
  • 本文由 发表于 2023年2月27日 09:07:48
  • 转载请务必保留本文链接:https://go.coder-hub.com/75576038.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定