diff --git a/crates/swc_css_minifier/src/compressor/declaration.rs b/crates/swc_css_minifier/src/compressor/declaration.rs index 45691d54b5b..b53b9ef3414 100644 --- a/crates/swc_css_minifier/src/compressor/declaration.rs +++ b/crates/swc_css_minifier/src/compressor/declaration.rs @@ -343,18 +343,18 @@ impl Compressor { ComponentValue::Ident(box Ident { value, span, .. }) if value.eq_ignore_ascii_case(&js_word!("normal")) => { - ComponentValue::Number(Box::new(Number { + ComponentValue::Integer(Box::new(Integer { span, - value: 400.0, + value: 400, raw: None, })) } ComponentValue::Ident(box Ident { value, span, .. }) if value.eq_ignore_ascii_case(&js_word!("bold")) => { - ComponentValue::Number(Box::new(Number { + ComponentValue::Integer(Box::new(Integer { span, - value: 700.0, + value: 700, raw: None, })) } diff --git a/crates/swc_css_minifier/src/compressor/rules.rs b/crates/swc_css_minifier/src/compressor/rules.rs index bb9063c343b..e7250addbab 100644 --- a/crates/swc_css_minifier/src/compressor/rules.rs +++ b/crates/swc_css_minifier/src/compressor/rules.rs @@ -58,6 +58,13 @@ impl Compressor { } } + fn get_declaration_name(&self, declaration: &Declaration) -> JsWord { + match &declaration.name { + DeclarationName::Ident(Ident { value, .. }) => value.to_ascii_lowercase(), + DeclarationName::DashedIdent(DashedIdent { value, .. }) => value.to_ascii_lowercase(), + } + } + fn collect_names(&self, at_rule: &AtRule, names: &mut AHashMap) { match &at_rule.prelude { Some(box AtRulePrelude::CounterStylePrelude(CustomIdent { value: name, .. })) => { @@ -532,6 +539,18 @@ impl Compressor { true } + ComponentValue::Declaration(box declaration) if prev_rule.is_some() => { + if let Some(ComponentValue::Declaration(box prev_rule)) = &mut prev_rule { + if self.get_declaration_name(prev_rule) + == self.get_declaration_name(declaration) + && prev_rule.value.eq_ignore_span(&declaration.value) + { + remove_rules_list.push(prev_index); + } + } + + true + } _ => { if let ComponentValue::AtRule(rule) = rule { self.collect_names(rule, &mut names); @@ -547,11 +566,14 @@ impl Compressor { prev_index = index; prev_rule_idx = Some(index); } - ComponentValue::QualifiedRule(_) => { prev_index = index; prev_rule_idx = Some(index); } + ComponentValue::Declaration(_) => { + prev_index = index; + prev_rule_idx = Some(index); + } _ => { prev_rule_idx = None; } diff --git a/crates/swc_css_minifier/tests/fixture/compress-color/output.min.css b/crates/swc_css_minifier/tests/fixture/compress-color/output.min.css index d3f0f476e26..28dc514a8de 100644 --- a/crates/swc_css_minifier/tests/fixture/compress-color/output.min.css +++ b/crates/swc_css_minifier/tests/fixture/compress-color/output.min.css @@ -1 +1 @@ -.color{color:rgb(from rgba(0,0,0,0)255 255 255)}.color-1,.color-2{color:rgb(from red 255 255 255)}.color-3{color:rgb(from#f00 255 255 255)}.color-4{color:rgb(from#eee8aa 255 255 255)}.color-5{color:rgb(from#ff0 255 255 255)}.color-6{color:rgb(from snow 255 255 255)}.color-7{color:rgba(123,123,123,0)}.color-8,.color-9,.color-10,.color-11{color:#7b7b7b}.color-12{color:rgba(51,102,77,.23)}.color-13{color:#7b7b7b}.color-14{color:#6496c8}.class-15{color:#7b7b7b}.class-16{color:rgba(123,123,123,.99)}.class-17{color:#7b7b7b}.class-18{color:rgba(179,82,31,.13)}.class-19{color:rgba(180,82,31,.13)}.class-20{color:rgba(181,82,31,.13)}.class-21{color:rgba(182,82,31,.13)}.class-22{color:rgba(184,82,31,.13)}.class-23{color:rgba(181,181,181,.13)}.class-24{color:rgba(182,181,181,.13)}.class-25{color:rgba(181,181,181,.1%)}.class-26{color:rgba(181,181,181,.4%)}.color-27{color:rgb(from#eee8aa 255 255 255)}.color-28{color:rgb(from teal 255 255 255)}.color-29,.color-30{color:rgb(from red 255 255 255)}.class-31{color:#ff0800;color:gray;color:#000;color:#80ff00;color:#a6ff00;color:#f9ff00;color:#80ff00;color:red;color:red;color:red;color:#00ffae;color:red;color:#ff00bf;color:#8000ff;color:#0040ff;color:#0ff;color:#00ff40;color:#80ff00;color:#ffbf00;color:red;color:red;color:#ff00bf;color:rgba(128,0,255,.5);color:rgba(0,64,255,.5);color:rgba(0,255,255,.5);color:rgba(0,255,64,.5);color:rgba(128,255,0,.5);color:rgba(255,191,0,.5);color:rgba(255,0,0,.5);color:red;color:#ff00bf;color:#8000ff;color:#0040ff;color:#0ff;color:#00ff40;color:#80ff00;color:#ffbf00;color:red;color:red;color:#ff00bf;color:rgba(128,0,255,.5);color:rgba(0,64,255,.5);color:rgba(0,255,255,.5);color:rgba(0,255,64,.5);color:rgba(128,255,0,.5);color:rgba(255,191,0,.5);color:rgba(255,0,0,.5);color:#ff0400;color:#ff0800;color:#ff0d00}.class-32{color:gray;color:#4d7f4d;color:#fff;color:#fd3;color:#ccb333;color:green;color:#000;color:gray;color:#33b333;color:gray;color:gray;color:rgba(128,128,128,.2);color:gray;color:rgba(128,128,128,.2);color:#6b8056;color:#4d7f4d;color:rgba(77,127,77,.5);color:red;color:red;color:rgba(255,0,0,0);color:rgba(255,0,0,0);color:#0f0;color:#0f0;color:#cfc;color:#cfc;color:green;color:green;color:rgba(77,127,77,0);color:rgba(77,127,77,0);color:rgba(170,170,170,0);color:rgba(170,170,170,0);color:#4d7f4d}.class-33{color:red}.class-34,.class-35{color:rgba(2,3,4,.5)}.class-36{color:#0f0}.class-37{color:rgba(0,255,0,.25)}.class-38{color:#000304}.class-39{color:#64c8ff}.class-40{color:rgba(20,10,0,0)}.class-41{color:#fff;color:#000}.class-42{color:rgba(0,0,0,0)}.class-43{color:maroon}.class-44{color:rgba(128,0,0,0)}.class-45{color:rgba(0,0,0,.5)}.class-46{color:#300}.class-47{color:rgba(51,0,0,0)}.class-48{color:rgba(0,0,0,.5)}.class-49{color:#000}.class-50{color:rgba(0,0,0,0)}.class-51{color:maroon}.class-52{color:rgba(128,0,0,0)}.class-53{color:rgba(0,0,0,.5)}.class-54{color:#300}.class-55{color:rgba(51,0,0,0)}.class-56{color:rgba(0,0,0,.5)}.class-57{color:#59a659}.class-58{color:rgba(77,127,77,.5)}.class-59,.class-60{color:red}.class-61,.class-62{color:rgba(255,0,0,0)}.class-63,.class-64{color:#0f0}.class-65,.class-66{color:#cfc}.class-67,.class-68{color:green}.class-69,.class-70{color:rgba(77,127,77,0)}.class-71,.class-72{color:rgba(170,170,170,0)}.class-73{color:#fff}.class-74{color:#000}.class-75{color:#fff}.class-76,.class-77,.class-78{color:#000}.class-79{color:#fff}.class-80,.class-81{color:#646464}.class-82,.class-83{color:rgba(100,100,100,0)} +.color{color:rgb(from rgba(0,0,0,0)255 255 255)}.color-1,.color-2{color:rgb(from red 255 255 255)}.color-3{color:rgb(from#f00 255 255 255)}.color-4{color:rgb(from#eee8aa 255 255 255)}.color-5{color:rgb(from#ff0 255 255 255)}.color-6{color:rgb(from snow 255 255 255)}.color-7{color:rgba(123,123,123,0)}.color-8,.color-9,.color-10,.color-11{color:#7b7b7b}.color-12{color:rgba(51,102,77,.23)}.color-13{color:#7b7b7b}.color-14{color:#6496c8}.class-15{color:#7b7b7b}.class-16{color:rgba(123,123,123,.99)}.class-17{color:#7b7b7b}.class-18{color:rgba(179,82,31,.13)}.class-19{color:rgba(180,82,31,.13)}.class-20{color:rgba(181,82,31,.13)}.class-21{color:rgba(182,82,31,.13)}.class-22{color:rgba(184,82,31,.13)}.class-23{color:rgba(181,181,181,.13)}.class-24{color:rgba(182,181,181,.13)}.class-25{color:rgba(181,181,181,.1%)}.class-26{color:rgba(181,181,181,.4%)}.color-27{color:rgb(from#eee8aa 255 255 255)}.color-28{color:rgb(from teal 255 255 255)}.color-29,.color-30{color:rgb(from red 255 255 255)}.class-31{color:#ff0800;color:gray;color:#000;color:#80ff00;color:#a6ff00;color:#f9ff00;color:#80ff00;color:red;color:#00ffae;color:red;color:#ff00bf;color:#8000ff;color:#0040ff;color:#0ff;color:#00ff40;color:#80ff00;color:#ffbf00;color:red;color:#ff00bf;color:rgba(128,0,255,.5);color:rgba(0,64,255,.5);color:rgba(0,255,255,.5);color:rgba(0,255,64,.5);color:rgba(128,255,0,.5);color:rgba(255,191,0,.5);color:rgba(255,0,0,.5);color:red;color:#ff00bf;color:#8000ff;color:#0040ff;color:#0ff;color:#00ff40;color:#80ff00;color:#ffbf00;color:red;color:#ff00bf;color:rgba(128,0,255,.5);color:rgba(0,64,255,.5);color:rgba(0,255,255,.5);color:rgba(0,255,64,.5);color:rgba(128,255,0,.5);color:rgba(255,191,0,.5);color:rgba(255,0,0,.5);color:#ff0400;color:#ff0800;color:#ff0d00}.class-32{color:gray;color:#4d7f4d;color:#fff;color:#fd3;color:#ccb333;color:green;color:#000;color:gray;color:#33b333;color:gray;color:rgba(128,128,128,.2);color:gray;color:rgba(128,128,128,.2);color:#6b8056;color:#4d7f4d;color:rgba(77,127,77,.5);color:red;color:rgba(255,0,0,0);color:#0f0;color:#cfc;color:green;color:rgba(77,127,77,0);color:rgba(170,170,170,0);color:#4d7f4d}.class-33{color:red}.class-34,.class-35{color:rgba(2,3,4,.5)}.class-36{color:#0f0}.class-37{color:rgba(0,255,0,.25)}.class-38{color:#000304}.class-39{color:#64c8ff}.class-40{color:rgba(20,10,0,0)}.class-41{color:#fff;color:#000}.class-42{color:rgba(0,0,0,0)}.class-43{color:maroon}.class-44{color:rgba(128,0,0,0)}.class-45{color:rgba(0,0,0,.5)}.class-46{color:#300}.class-47{color:rgba(51,0,0,0)}.class-48{color:rgba(0,0,0,.5)}.class-49{color:#000}.class-50{color:rgba(0,0,0,0)}.class-51{color:maroon}.class-52{color:rgba(128,0,0,0)}.class-53{color:rgba(0,0,0,.5)}.class-54{color:#300}.class-55{color:rgba(51,0,0,0)}.class-56{color:rgba(0,0,0,.5)}.class-57{color:#59a659}.class-58{color:rgba(77,127,77,.5)}.class-59,.class-60{color:red}.class-61,.class-62{color:rgba(255,0,0,0)}.class-63,.class-64{color:#0f0}.class-65,.class-66{color:#cfc}.class-67,.class-68{color:green}.class-69,.class-70{color:rgba(77,127,77,0)}.class-71,.class-72{color:rgba(170,170,170,0)}.class-73{color:#fff}.class-74{color:#000}.class-75{color:#fff}.class-76,.class-77,.class-78{color:#000}.class-79{color:#fff}.class-80,.class-81{color:#646464}.class-82,.class-83{color:rgba(100,100,100,0)} diff --git a/crates/swc_css_minifier/tests/fixture/compress-declaration/duplication/input.css b/crates/swc_css_minifier/tests/fixture/compress-declaration/duplication/input.css new file mode 100644 index 00000000000..f3e4ba205f6 --- /dev/null +++ b/crates/swc_css_minifier/tests/fixture/compress-declaration/duplication/input.css @@ -0,0 +1,108 @@ +a { + color: red; + color: red; + + .class { + color: red; + color: red; + } + + @media screen and (min-width: 100px) { + color: red; + color: red; + } + + @supports (display: flex) { + color: red; + color: red; + + .other { + color: red; + color: red; + } + } + + .case-insensitivity { + color: red; + COLOR: red; + } +} + +.font { + > h1 { font-weight: bold } + > h1 { font-weight: 700 } +} + +.class { + > h1 { font-weight: bold } + > h1 { font-weight: bold } +} + +.other { + > h1 { font-weight: 700 } + > h1 { font-weight: 700 } +} + +.base { + color: red; + + .class { + color: red; + } + + .class-other { + color: red; + } + + @media screen { + .class { + color: red; + } + + .class-other { + color: red; + } + } +} + +h1{/*test*/font-weight:bold} +h1{/*test*/font-weight:bold} + +.white { + _color:white; + color:white +} + +h1,h2{font-weight:bold} +h2,h1{font-weight:bold} + +.margin{margin:10px 0 10px 0;margin:10px 0} + +h1{font-weight:bold;font-weight:bold} +h1{font-weight:bold} + +@media print{ + h1 { + display:block + } +} +@media print{ + h1 { + display:block + } +} + +.other { + & h1 { font-weight: bold } + & h1 { font-weight: bold } +} + +@media print{ + h1, h2 { + font-weight:bold + } + + h2, h1{ + font-weight:bold + } +} diff --git a/crates/swc_css_minifier/tests/fixture/compress-declaration/duplication/output.min.css b/crates/swc_css_minifier/tests/fixture/compress-declaration/duplication/output.min.css new file mode 100644 index 00000000000..f845eeee6f5 --- /dev/null +++ b/crates/swc_css_minifier/tests/fixture/compress-declaration/duplication/output.min.css @@ -0,0 +1 @@ +a{color:red;.class{color:red}@media screen and (min-width:100px){color:red}@supports(display:flex){color:red;.other{color:red}}.case-insensitivity{color:red}}.font,.class,.other{>h1{font-weight:700}}.base{color:red;.class,.class-other{color:red}@media screen{.class,.class-other{color:red}}}h1{font-weight:700}.white{_color:white;color:white}h1,h2{font-weight:700}.margin{margin:10px 0}h1{font-weight:700}@media print{h1{display:block}}.other{& h1{font-weight:700}}@media print{h1,h2{font-weight:700}} diff --git a/crates/swc_css_minifier/tests/fixture/compress-declaration/font-weight/output.min.css b/crates/swc_css_minifier/tests/fixture/compress-declaration/font-weight/output.min.css index f7cf60c3aeb..374a3b2ac50 100644 --- a/crates/swc_css_minifier/tests/fixture/compress-declaration/font-weight/output.min.css +++ b/crates/swc_css_minifier/tests/fixture/compress-declaration/font-weight/output.min.css @@ -1 +1 @@ -.class1{font-weight:1;font-weight:400;font-weight:1000}.class2{font-weight:400}.class3{font-weight:700;font-weight:700}.class4{font-weight:400 700}.class5{font-weight:600 700} +.class1{font-weight:1;font-weight:400;font-weight:1000}.class2{font-weight:400}.class3{font-weight:700}.class4{font-weight:400 700}.class5{font-weight:600 700} diff --git a/crates/swc_css_minifier/tests/fixture/compress-declaration/initial/output.min.css b/crates/swc_css_minifier/tests/fixture/compress-declaration/initial/output.min.css index 70ff2ab9ed6..fe81eca1023 100644 --- a/crates/swc_css_minifier/tests/fixture/compress-declaration/initial/output.min.css +++ b/crates/swc_css_minifier/tests/fixture/compress-declaration/initial/output.min.css @@ -1 +1 @@ -.a{cursor:auto;cursor:auto;accent-color:auto;accent-color:auto;accent-color:auto;appearance:none;animation-direction:normal;animation-delay:0s;opacity:0;animation-iteration-count:1;animation-timing-function:ease;mask-position:center;background-attachment:scroll;background-position:0%0%;background-position-x:0%;background-repeat:repeat;orphans:2;transition-property:all;transform-style:flat;text-overflow:clip;text-orientation:mixed;text-decoration-style:solid;tab-size:8;scroll-timeline-axis:block;position:static;block-overflow:clip;font-size:medium;flex-direction:row;mask-border-slice:0;border-image-slice:100%;border-image-width:1;box-decoration-break:slice;caption-side:top;direction:ltr;empty-cells:show;flex-grow:0;flex-shrink:1;flex-wrap:nowrap;hyphens:manual;image-resolution:1dppx;justify-items:legacy;list-style-type:disk;mask-border-mode:alpha;mask-composite:add;masonry-auto-flow:pack;order:0;object-fit:fill;border-top-left-radius:0;padding-top:0;padding-right:0;padding-bottom:0;padding-left:0;padding:0;overflow-clip-margin:0}.b{background-clip:border-box;background-color:transparent;background-origin:padding-box;background-size:auto auto;border-block-color:currentcolor;border-block-end-color:currentcolor;border-block-start-color:currentcolor;border-bottom-color:currentcolor;border-collapse:separate;border-inline-color:currentcolor;border-inline-end-color:currentcolor;border-inline-start-color:currentcolor;border-left-color:currentcolor;border-right-color:currentcolor;border-top-color:currentcolor;box-sizing:content-box;color:canvastext;column-rule-color:currentcolor;font-synthesis:weight style;image-orientation:from-image;mask-clip:border-box;mask-mode:match-source;mask-origin:border-box;mask-type:luminance;ruby-align:space-around;ruby-merge:separate;ruby-position:alternate;text-decoration-color:currentcolor;text-emphasis-color:currentcolor;text-emphasis-position:over right;transform-box:view-box;transform-origin:50%50%0;vertical-align:baseline;writing-mode:horizontal-tb}.c{-webkit-line-clamp:none;accent-color:auto;align-content:normal;align-items:normal;align-self:auto;align-tracks:normal;animation-delay:0s;animation-direction:normal;animation-duration:0s;animation-fill-mode:none;animation-iteration-count:1;animation-name:none;animation-timing-function:ease;animation-timeline:auto;appearance:none;aspect-ratio:auto;azimuth:center;backdrop-filter:none;background-attachment:scroll;background-blend-mode:normal;background-image:none;background-position:0%0%;background-position-x:0%;background-position-y:0%;background-repeat:repeat;block-overflow:clip;block-size:auto;border-block-style:none;border-block-width:medium;border-block-end-style:none;border-block-end-width:medium;border-block-start-style:none;border-block-start-width:medium;border-bottom-left-radius:0;border-bottom-right-radius:0;border-bottom-style:none;border-bottom-width:medium;border-end-end-radius:0;border-end-start-radius:0;border-image-outset:0;border-image-slice:100%;border-image-source:none;border-image-width:1;border-inline-style:none;border-inline-width:medium;border-inline-end-style:none;border-inline-end-width:medium;border-inline-start-style:none;border-inline-start-width:medium;border-left-style:none;border-left-width:medium;border-right-style:none;border-right-width:medium;border-spacing:0;border-start-end-radius:0;border-start-start-radius:0;border-top-left-radius:0;border-top-right-radius:0;border-top-style:none;border-top-width:medium;bottom:auto;box-decoration-break:slice;box-shadow:none;break-after:auto;break-before:auto;break-inside:auto;caption-side:top;caret-color:auto;caret-shape:auto;clear:none;clip:auto;clip-path:none;color-scheme:normal;column-count:auto;column-gap:normal;column-rule-style:none;column-rule-width:medium;column-span:none;column-width:auto;contain:none;contain-intrinsic-block-size:none;contain-intrinsic-height:none;contain-intrinsic-inline-size:none;contain-intrinsic-width:none;content:normal;counter-increment:none;counter-reset:none;counter-set:none;cursor:auto;direction:ltr;empty-cells:show;filter:none;flex-basis:auto;flex-direction:row;flex-grow:0;flex-shrink:1;flex-wrap:nowrap;float:none;font-feature-settings:normal;font-kerning:auto;font-language-override:normal;font-optical-sizing:auto;font-variation-settings:normal;font-size:medium;font-size-adjust:none;font-stretch:normal;font-style:normal;font-variant:normal;font-variant-alternates:normal;font-variant-caps:normal;font-variant-east-asian:normal;font-variant-ligatures:normal;font-variant-numeric:normal;font-variant-position:normal;font-weight:normal;forced-color-adjust:auto;grid-auto-columns:auto;grid-auto-flow:row;grid-auto-rows:auto;grid-column-end:auto;grid-column-gap:normal;grid-column-start:auto;grid-row-end:auto;grid-row-gap:normal;grid-row-start:auto;grid-template-areas:none;grid-template-columns:none;grid-template-rows:none;hanging-punctuation:none;height:auto;hyphenate-character:auto;hyphens:manual;image-rendering:auto;image-resolution:1dppx;ime-mode:auto;initial-letter:normal;initial-letter-align:auto;inline-size:auto;input-security:auto;inset:auto;inset-block:auto;inset-block-end:auto;inset-block-start:auto;inset-inline:auto;inset-inline-end:auto;inset-inline-start:auto;isolation:auto;justify-content:normal;justify-items:legacy;justify-self:auto;justify-tracks:normal;left:auto;letter-spacing:normal;line-break:auto;line-clamp:none;line-height:normal;line-height-step:0;list-style-image:none;list-style-type:disk;margin-block:0;margin-block-end:0;margin-block-start:0;margin-bottom:0;margin-inline:0;margin-inline-end:0;margin-inline-start:0;margin-left:0;margin-right:0;margin-top:0;margin-trim:none;mask-border-mode:alpha;mask-border-outset:0;mask-border-slice:0;mask-border-source:none;mask-border-width:auto;mask-composite:add;mask-image:none;mask-position:center;mask-repeat:repeat;mask-size:auto;masonry-auto-flow:pack;math-depth:0;math-shift:normal;math-style:normal;max-block-size:none;max-height:none;max-inline-size:none;max-lines:none;max-width:none;min-block-size:0;min-height:auto;min-inline-size:0;min-width:auto;mix-blend-mode:normal;object-fit:fill;offset-anchor:auto;offset-distance:0;offset-path:none;offset-position:auto;offset-rotate:auto;opacity:0;order:0;orphans:2;outline-offset:0;outline-style:none;outline-width:medium;overflow-anchor:auto;overflow-block:auto;overflow-clip-margin:0;overflow-inline:auto;overflow-wrap:normal;overscroll-behavior:auto;overscroll-behavior-block:auto;overscroll-behavior-inline:auto;overscroll-behavior-x:auto;overscroll-behavior-y:auto;padding-block:0;padding-block-end:0;padding-block-start:0;padding-bottom:0;padding-inline:0;padding-inline-end:0;padding-inline-start:0;padding-left:0;padding-right:0;padding-top:0;page-break-after:auto;page-break-before:auto;page-break-inside:auto;paint-order:normal;perspective:none;place-content:normal;pointer-events:auto;position:static;resize:none;right:auto;rotate:none;row-gap:normal;scale:none;scrollbar-color:auto;scrollbar-gutter:auto;scrollbar-width:auto;scroll-behavior:auto;scroll-margin:0;scroll-margin-block:0;scroll-margin-block-start:0;scroll-margin-block-end:0;scroll-margin-bottom:0;scroll-margin-inline:0;scroll-margin-inline-start:0;scroll-margin-inline-end:0;scroll-margin-left:0;scroll-margin-right:0;scroll-margin-top:0;scroll-padding:auto;scroll-padding-block:auto;scroll-padding-block-start:auto;scroll-padding-block-end:auto;scroll-padding-bottom:auto;scroll-padding-inline:auto;scroll-padding-inline-start:auto;scroll-padding-inline-end:auto;scroll-padding-left:auto;scroll-padding-right:auto;scroll-padding-top:auto;scroll-snap-align:none;scroll-snap-coordinate:none;scroll-snap-points-x:none;scroll-snap-points-y:none;scroll-snap-stop:normal;scroll-snap-type:none;scroll-snap-type-x:none;scroll-snap-type-y:none;scroll-timeline-axis:block;scroll-timeline-name:none;shape-image-threshold:0;shape-margin:0;shape-outside:none;tab-size:8;table-layout:auto;text-align-last:auto;text-combine-upright:none;text-decoration-line:none;text-decoration-skip-ink:auto;text-decoration-style:solid;text-decoration-thickness:auto;text-emphasis-style:none;text-indent:0;text-justify:auto;text-orientation:mixed;text-overflow:clip;text-rendering:auto;text-shadow:none;text-transform:none;text-underline-offset:auto;text-underline-position:auto;top:auto;touch-action:auto;transform:none;transform-style:flat;transition-delay:0s;transition-duration:0s;transition-property:all;transition-timing-function:ease;translate:none;unicode-bidi:normal;user-select:auto;white-space:normal;widows:2;width:auto;will-change:auto;word-break:normal;word-spacing:normal;word-wrap:normal;z-index:auto}@supports(cursor:INITIAL){a{background:red}}a{>b{position:static}@media screen{position:static}} +.a{cursor:auto;accent-color:auto;appearance:none;animation-direction:normal;animation-delay:0s;opacity:0;animation-iteration-count:1;animation-timing-function:ease;mask-position:center;background-attachment:scroll;background-position:0%0%;background-position-x:0%;background-repeat:repeat;orphans:2;transition-property:all;transform-style:flat;text-overflow:clip;text-orientation:mixed;text-decoration-style:solid;tab-size:8;scroll-timeline-axis:block;position:static;block-overflow:clip;font-size:medium;flex-direction:row;mask-border-slice:0;border-image-slice:100%;border-image-width:1;box-decoration-break:slice;caption-side:top;direction:ltr;empty-cells:show;flex-grow:0;flex-shrink:1;flex-wrap:nowrap;hyphens:manual;image-resolution:1dppx;justify-items:legacy;list-style-type:disk;mask-border-mode:alpha;mask-composite:add;masonry-auto-flow:pack;order:0;object-fit:fill;border-top-left-radius:0;padding-top:0;padding-right:0;padding-bottom:0;padding-left:0;padding:0;overflow-clip-margin:0}.b{background-clip:border-box;background-color:transparent;background-origin:padding-box;background-size:auto auto;border-block-color:currentcolor;border-block-end-color:currentcolor;border-block-start-color:currentcolor;border-bottom-color:currentcolor;border-collapse:separate;border-inline-color:currentcolor;border-inline-end-color:currentcolor;border-inline-start-color:currentcolor;border-left-color:currentcolor;border-right-color:currentcolor;border-top-color:currentcolor;box-sizing:content-box;color:canvastext;column-rule-color:currentcolor;font-synthesis:weight style;image-orientation:from-image;mask-clip:border-box;mask-mode:match-source;mask-origin:border-box;mask-type:luminance;ruby-align:space-around;ruby-merge:separate;ruby-position:alternate;text-decoration-color:currentcolor;text-emphasis-color:currentcolor;text-emphasis-position:over right;transform-box:view-box;transform-origin:50%50%0;vertical-align:baseline;writing-mode:horizontal-tb}.c{-webkit-line-clamp:none;accent-color:auto;align-content:normal;align-items:normal;align-self:auto;align-tracks:normal;animation-delay:0s;animation-direction:normal;animation-duration:0s;animation-fill-mode:none;animation-iteration-count:1;animation-name:none;animation-timing-function:ease;animation-timeline:auto;appearance:none;aspect-ratio:auto;azimuth:center;backdrop-filter:none;background-attachment:scroll;background-blend-mode:normal;background-image:none;background-position:0%0%;background-position-x:0%;background-position-y:0%;background-repeat:repeat;block-overflow:clip;block-size:auto;border-block-style:none;border-block-width:medium;border-block-end-style:none;border-block-end-width:medium;border-block-start-style:none;border-block-start-width:medium;border-bottom-left-radius:0;border-bottom-right-radius:0;border-bottom-style:none;border-bottom-width:medium;border-end-end-radius:0;border-end-start-radius:0;border-image-outset:0;border-image-slice:100%;border-image-source:none;border-image-width:1;border-inline-style:none;border-inline-width:medium;border-inline-end-style:none;border-inline-end-width:medium;border-inline-start-style:none;border-inline-start-width:medium;border-left-style:none;border-left-width:medium;border-right-style:none;border-right-width:medium;border-spacing:0;border-start-end-radius:0;border-start-start-radius:0;border-top-left-radius:0;border-top-right-radius:0;border-top-style:none;border-top-width:medium;bottom:auto;box-decoration-break:slice;box-shadow:none;break-after:auto;break-before:auto;break-inside:auto;caption-side:top;caret-color:auto;caret-shape:auto;clear:none;clip:auto;clip-path:none;color-scheme:normal;column-count:auto;column-gap:normal;column-rule-style:none;column-rule-width:medium;column-span:none;column-width:auto;contain:none;contain-intrinsic-block-size:none;contain-intrinsic-height:none;contain-intrinsic-inline-size:none;contain-intrinsic-width:none;content:normal;counter-increment:none;counter-reset:none;counter-set:none;cursor:auto;direction:ltr;empty-cells:show;filter:none;flex-basis:auto;flex-direction:row;flex-grow:0;flex-shrink:1;flex-wrap:nowrap;float:none;font-feature-settings:normal;font-kerning:auto;font-language-override:normal;font-optical-sizing:auto;font-variation-settings:normal;font-size:medium;font-size-adjust:none;font-stretch:normal;font-style:normal;font-variant:normal;font-variant-alternates:normal;font-variant-caps:normal;font-variant-east-asian:normal;font-variant-ligatures:normal;font-variant-numeric:normal;font-variant-position:normal;font-weight:normal;forced-color-adjust:auto;grid-auto-columns:auto;grid-auto-flow:row;grid-auto-rows:auto;grid-column-end:auto;grid-column-gap:normal;grid-column-start:auto;grid-row-end:auto;grid-row-gap:normal;grid-row-start:auto;grid-template-areas:none;grid-template-columns:none;grid-template-rows:none;hanging-punctuation:none;height:auto;hyphenate-character:auto;hyphens:manual;image-rendering:auto;image-resolution:1dppx;ime-mode:auto;initial-letter:normal;initial-letter-align:auto;inline-size:auto;input-security:auto;inset:auto;inset-block:auto;inset-block-end:auto;inset-block-start:auto;inset-inline:auto;inset-inline-end:auto;inset-inline-start:auto;isolation:auto;justify-content:normal;justify-items:legacy;justify-self:auto;justify-tracks:normal;left:auto;letter-spacing:normal;line-break:auto;line-clamp:none;line-height:normal;line-height-step:0;list-style-image:none;list-style-type:disk;margin-block:0;margin-block-end:0;margin-block-start:0;margin-bottom:0;margin-inline:0;margin-inline-end:0;margin-inline-start:0;margin-left:0;margin-right:0;margin-top:0;margin-trim:none;mask-border-mode:alpha;mask-border-outset:0;mask-border-slice:0;mask-border-source:none;mask-border-width:auto;mask-composite:add;mask-image:none;mask-position:center;mask-repeat:repeat;mask-size:auto;masonry-auto-flow:pack;math-depth:0;math-shift:normal;math-style:normal;max-block-size:none;max-height:none;max-inline-size:none;max-lines:none;max-width:none;min-block-size:0;min-height:auto;min-inline-size:0;min-width:auto;mix-blend-mode:normal;object-fit:fill;offset-anchor:auto;offset-distance:0;offset-path:none;offset-position:auto;offset-rotate:auto;opacity:0;order:0;orphans:2;outline-offset:0;outline-style:none;outline-width:medium;overflow-anchor:auto;overflow-block:auto;overflow-clip-margin:0;overflow-inline:auto;overflow-wrap:normal;overscroll-behavior:auto;overscroll-behavior-block:auto;overscroll-behavior-inline:auto;overscroll-behavior-x:auto;overscroll-behavior-y:auto;padding-block:0;padding-block-end:0;padding-block-start:0;padding-bottom:0;padding-inline:0;padding-inline-end:0;padding-inline-start:0;padding-left:0;padding-right:0;padding-top:0;page-break-after:auto;page-break-before:auto;page-break-inside:auto;paint-order:normal;perspective:none;place-content:normal;pointer-events:auto;position:static;resize:none;right:auto;rotate:none;row-gap:normal;scale:none;scrollbar-color:auto;scrollbar-gutter:auto;scrollbar-width:auto;scroll-behavior:auto;scroll-margin:0;scroll-margin-block:0;scroll-margin-block-start:0;scroll-margin-block-end:0;scroll-margin-bottom:0;scroll-margin-inline:0;scroll-margin-inline-start:0;scroll-margin-inline-end:0;scroll-margin-left:0;scroll-margin-right:0;scroll-margin-top:0;scroll-padding:auto;scroll-padding-block:auto;scroll-padding-block-start:auto;scroll-padding-block-end:auto;scroll-padding-bottom:auto;scroll-padding-inline:auto;scroll-padding-inline-start:auto;scroll-padding-inline-end:auto;scroll-padding-left:auto;scroll-padding-right:auto;scroll-padding-top:auto;scroll-snap-align:none;scroll-snap-coordinate:none;scroll-snap-points-x:none;scroll-snap-points-y:none;scroll-snap-stop:normal;scroll-snap-type:none;scroll-snap-type-x:none;scroll-snap-type-y:none;scroll-timeline-axis:block;scroll-timeline-name:none;shape-image-threshold:0;shape-margin:0;shape-outside:none;tab-size:8;table-layout:auto;text-align-last:auto;text-combine-upright:none;text-decoration-line:none;text-decoration-skip-ink:auto;text-decoration-style:solid;text-decoration-thickness:auto;text-emphasis-style:none;text-indent:0;text-justify:auto;text-orientation:mixed;text-overflow:clip;text-rendering:auto;text-shadow:none;text-transform:none;text-underline-offset:auto;text-underline-position:auto;top:auto;touch-action:auto;transform:none;transform-style:flat;transition-delay:0s;transition-duration:0s;transition-property:all;transition-timing-function:ease;translate:none;unicode-bidi:normal;user-select:auto;white-space:normal;widows:2;width:auto;will-change:auto;word-break:normal;word-spacing:normal;word-wrap:normal;z-index:auto}@supports(cursor:INITIAL){a{background:red}}a{>b{position:static}@media screen{position:static}} diff --git a/crates/swc_css_minifier/tests/fixture/compress-frequency/output.min.css b/crates/swc_css_minifier/tests/fixture/compress-frequency/output.min.css index 6f5ef615366..5687b75fdfb 100644 --- a/crates/swc_css_minifier/tests/fixture/compress-frequency/output.min.css +++ b/crates/swc_css_minifier/tests/fixture/compress-frequency/output.min.css @@ -1 +1 @@ -div{prop:0hz;prop:0hz;prop:1hz;prop:10hz;prop:100hz;prop:101hz;prop:500hz;prop:500hz;prop:999hz;prop:1khz;prop:2khz;prop:5khz;prop:9999hz;prop:10khz;prop:50khz;prop:50005hz;prop:500005hz;prop:5000005hz;prop:0hz;prop:0hz;prop:1khz;prop:10khz;prop:100khz;prop:1e3khz;prop:1e4khz;prop:5e4khz;prop:50005khz;prop:1hz;prop:.1hz;prop:1hz;prop:5hz;prop:50hz;prop:50hz;prop:.5khz;prop:.1khz;prop:.543khz} +div{prop:0hz;prop:1hz;prop:10hz;prop:100hz;prop:101hz;prop:500hz;prop:999hz;prop:1khz;prop:2khz;prop:5khz;prop:9999hz;prop:10khz;prop:50khz;prop:50005hz;prop:500005hz;prop:5000005hz;prop:0hz;prop:1khz;prop:10khz;prop:100khz;prop:1e3khz;prop:1e4khz;prop:5e4khz;prop:50005khz;prop:1hz;prop:.1hz;prop:1hz;prop:5hz;prop:50hz;prop:.5khz;prop:.1khz;prop:.543khz} diff --git a/crates/swc_css_minifier/tests/fixture/compress-rules/output.min.css b/crates/swc_css_minifier/tests/fixture/compress-rules/output.min.css index 551053061f9..06460bbaac5 100644 --- a/crates/swc_css_minifier/tests/fixture/compress-rules/output.min.css +++ b/crates/swc_css_minifier/tests/fixture/compress-rules/output.min.css @@ -1 +1 @@ -a,p{color:blue;font-weight:700}.break{color:red}h1,h2{color:red;line-height:1.5;font-size:2em}.break{color:red}h1{color:red;line-height:1.5;font-size:2em}h2{font-size:2em;color:red;line-height:1.5}.break{color:red}h1,h2,h3{color:red;line-height:1.5;font-size:2em}.break{color:red}h1,h2{color:red;line-height:1.5;font-size:2em}.break{color:red}h1{color:blue;font-weight:700}.break{color:red}h1{display:block;text-decoration:underline}.break{color:red}h1{color:red;display:block;text-decoration:underline}.break{color:red}h1{font-size:2em;color:#000;background:#fff;line-height:1.5}.break{color:red}@media print{h1{display:block;color:red}}.break{color:red}code::selection{background:red}code::-moz-selection{background:red}.break{color:red}.foo{&.bar{color:red}}.break{color:red}.foo{&.bar{color:red}}.break{color:red}.foo{@media screen{&.bar{color:red}}}.break{color:red}@media print{h1,p{display:block}}.break{color:red}@media print{h1{color:red;text-decoration:none}h2{text-decoration:none}}h3{text-decoration:none}.break{color:red}h3{text-decoration:none}@media print{h1{color:red;text-decoration:none}h2{text-decoration:none}}.break{color:red}@media screen and (max-width:480px){h1{display:block}}@media screen and (min-width:480px){h2{display:block}}.break{color:red}@media screen and (max-width:200px){h1{color:red}}@media screen and (min-width:480px){h1{display:block}}.break{color:red}@-webkit-keyframes test{0%{color:#000}to{color:#fff}}@keyframes test{0%{color:#000}to{color:#fff}}.break{color:red}h1{display:block}@media print{h1{color:red}}.break{color:red}@media print{h1{display:block}}h1,.break{color:red}h2{color:red;text-decoration:underline}.break,h1{color:red}h2{color:red;text-decoration:underline}h3{color:green;text-decoration:underline}.break{color:red}h1{color:red;text-decoration:underline}h2{text-decoration:underline;color:green}h3{font-weight:700;color:green}.break{color:red}.test0{color:red;border:none;margin:0}.test1{color:green;border:none;margin:0}.break{color:red}h1{color:red;font-weight:700}h2{font-weight:700}h3{text-decoration:none}.break{color:red}.test-1,.test-2{margin-top:10px}.another-test{margin-top:10px;margin-bottom:30px}.break{color:red}.test-1{margin-top:10px;margin-bottom:20px}.test-2{margin-top:10px}.another-test{margin-top:10px;margin-bottom:30px}.break{color:red}.foo{margin:0;display:block}.barim{display:block;line-height:1}.bazaz{font-size:3em;margin:0}.break{color:red}.foobam{font-family:serif;display:block}.barim{display:block;line-height:1}.bazaz{font-size:3em;font-family:serif}.break{color:red}.foo{font-family:serif;display:block}.barim{display:block;line-height:1}.bazaz{font-size:3em;font-family:serif}.break{color:red}h1{border:1px solid red;background-color:red;background-position:50%100%;border:1px solid red;background-color:red;border:1px solid red}.break{color:red}h1{color:black}h2,h3{color:black;font-weight:700}.break{color:red}.test0{color:red;border:none;margin:0}.longlonglonglong{color:green;border:none;margin:0}.break{color:red}code::-moz-selection{background:red}code::-moz-selection{background:red}.break{color:red}code:-ms-input-placeholder{background:red}code::-ms-input-placeholder{background:red}.break{color:red}input[type=range]{-webkit-appearance:none!important}input[type=range]::-webkit-slider-runnable-track{height:2px;width:100px;background:red;border:none}input[type=range]::-webkit-slider-thumb{-webkit-appearance:none!important;border:none;width:10px;height:10px;background:red}input[type=range]::-moz-range-thumb{border:none;width:10px;height:10px;background:red}.break{color:red}h1{color:red;text-align:right;text-decoration:underline}h2{text-align:right;text-decoration:underline}.break{color:red}h1{color:red;text-align:right;text-decoration:underline}h2{text-align:right;text-decoration:underline;color:green}.break{color:red}h1{background:white;color:red;text-align:right;text-decoration:underline}h2{text-align:right;text-decoration:underline;color:red}.break{color:red}h1{color:red;text-align:center;text-transform:small-caps}h2{text-align:center;color:red}.break{color:red}h1{text-align:left;text-transform:small-caps}h2{text-align:right;text-transform:small-caps}.break{color:red}@keyframes a{0%{transform-origin:right bottom;transform:rotate(-90deg);opacity:0}to{transform-origin:right bottom;transform:rotate(0);opacity:1}}.break{color:red}h2{margin-bottom:20px}h1{margin:10px;margin-bottom:20px}.break{color:red}h2{color:red;margin-bottom:20px}h1{color:red;margin:10px;margin-bottom:20px}.break{color:red}h2{margin:0;margin-bottom:20px}h1{margin:0;margin-top:20px}.break{color:red}h2{margin:0}h1{margin-top:20px;margin:0}.break{color:red}.box1{display:inline-block;display:block}.box2{display:inline-block}.break{color:red}h1,h2{display:block;display:block}.break{color:red}.a{-webkit-transform:translatex(-50%)translatey(-50%)rotate(270deg);-webkit-overflow-scrolling:touch}.b{-webkit-transform:translatex(-50%)translatey(-50%)rotate(270deg)}.break{color:red}h1,h2{display:block}.break{color:red}.one,.two,.three{font-family:"lorem";font-weight:400}.four{font-family:"lorem",serif;font-weight:400}.five{font-family:"lorem";font-weight:400}@font-face{font-family:"lorem";font-weight:400;src:url(/assets/lorem.eot);src:url(/assets/lorem.eot?#iefix)format("embedded-opentype"),url(/assets/lorem.woff)format("woff"),url(/assets/lorem.ttf)format("truetype")}.break{color:red}.foo{font-weight:400}.bar{font-family:"my-font";font-weight:400}@font-face{font-family:"my-font";font-weight:400;src:url(my-font.ttf)}.break{color:red}.a{font-family:Arial;font-family:Helvetica}.b{font-family:Arial}.break{color:red}.a{-webkit-transform:translatex(-50%)translatey(-50%)rotate(270deg);-webkit-overflow-scrolling:touch}.b{-webkit-transform:translatex(-50%)translatey(-50%)rotate(270deg)}.break{color:red}body{overflow:hidden;overflow-y:scroll;overflow-x:hidden}main{overflow:hidden}.break{color:red}.a{border-color:transparent;border-bottom-color:#111;border-bottom-style:solid}.b{border-color:transparent;border-bottom-color:#222;border-bottom-style:solid}.break{color:red}.fb-col-md-6{color:red;border-color:blue;flex:0 0 auto;flex-basis:50%}.fb-col-md-7{color:red;border-color:blue;flex:0 0 auto;flex-basis:58.3%}.break{color:red}.one{border:1px solid black;border-top:none}.two{border:1px solid black}.break{color:red}.dispendium-theme.fr-toolbar.fr-top{border-radius:0;background-clip:padding-box;box-shadow:none;border:1px solid#e0e0e0;border-bottom:0}.dispendium-theme.fr-toolbar.fr-bottom{border-radius:0;background-clip:padding-box;box-shadow:none;border:1px solid#e0e0e0;border-top:0}.break{color:red}.share .comment-count:before{content:" ";position:absolute;width:0;height:0;right:7px;top:26px;border:5px solid;border-color:#326891#326891 transparent transparent}.share .comment-count:after{content:" ";position:absolute;width:0;height:0;right:8px;top:24px;border:5px solid;border-color:#fff#fff transparent transparent}.break{color:red}@keyframes foo{0%{visibility:visible;transform:scale3d(.85,.85,.85);opacity:0}to{visibility:visible;opacity:1}}.break{color:red}.foo{background:#fff;-webkit-background-clip:text}.bar{background:#000;-webkit-background-clip:text}.break{color:red}.a{background-color:#fff;background-color:#717f83;color:#fff}.break{color:red}::placeholder{color:blue}h1{color:blue}.break{color:red}div,a~b{color:#fff}.break{color:red}div,a>b{color:#fff}.break{color:red}div,[href]{color:#fff}.break{color:red}div,[href=foo]{color:#fff}.break{color:red}div,[href~=foo]{color:#fff}.break{color:red}div,[href|=foo]{color:#fff}.break{color:red}div,[href^=foo]{color:#fff}.break{color:red}div,[href$=foo]{color:#fff}.break{color:red}div,[href*=foo]{color:#fff}.break{color:red}div{color:#fff}[href=foo i]{color:#fff}.break{color:red}:active{color:blue}h1{color:blue}.break{color:red}:after{color:blue}h1{color:blue}.break{color:red}:after{color:blue}h1{color:blue}.break{color:red}::placeholder{color:blue}h1{color:blue}.break{color:red}:host(tag){display:block}a{display:block}.break{color:red}p{color:blue}:unknown{color:blue}.break{color:red}p{color:blue}::unknown{color:blue}.break{color:red}@media print{h1{display:block;color:red}}.break{color:red}@media print{h1{display:block;color:red}}.break{color:red}@media(min-width:48rem){.wrapper{display:block}}@supports(display:flex){@media(min-width:48rem){.wrapper{display:flex}}}.break{color:red}@media print{h1{display:block;color:red}h2{padding:10px}}.break{color:red}@media print{h1{display:block;color:red}h2{padding:10px}}.break{color:red}@media(width:40px){.red{color:red}.green{color:green}.blue{color:blue}}@supports(--var:var){.white{color:white}.black{color:black}}.break{color:red}@media(width:40px){.red{color:red}.green{color:green}.blue{color:blue}}@supports(--var:var){@media(width:40px){.white{color:white}.black{color:black}}}.break{color:red}@media print{h1{display:block}}@media screen{h1{color:red}h2{padding:10px}}.break{color:red}@media(min-width:48rem){.wrapper{display:block}}@supports(display:flex){@media(min-width:48rem){.wrapper{display:flex}}}.break{color:red}@media print{h1{display:block}}@supports(color:red){@media print and (color:1){h1{color:red}h2{padding:10px}}}.break{color:red}@media(width:40px){h1{border:1px solid red;background-color:red;background-position:50%100%;border:1px solid red;background-color:red;border:1px solid red}}.break{color:red}@media(width:40px){h1{color:black}h2,h3{color:black;font-weight:700}}.break{color:red}.a{color:red;display:flex;font-size:10px}.c{all:unset;color:red;display:flex;font-size:10px}.break,.foo{color:red}.bar{all:unset;color:red}.break{color:red}.a{color:red;display:flex;font-size:10px;direction:tlr}.c{all:unset;color:red;display:flex;font-size:10px;direction:tlr}.break{color:red}a{color:green}a:focus-visible{color:green}a:focus-visible{background:red}.break{color:red}a,a:link{color:#555}a:visited{color:#555}.break{color:red}h1{color:#001;color:#002;color:#003}h2{color:#001;color:#002}.break{color:red}.foo,.bar{@media screen{color:red}}.break{color:red}.foo{@media screen{color:red}}.break{color:red}.foo{@media screen{color:red}@media print{color:red}}.break{color:red}@supports(display:flex){.flex-container>*{text-shadow:0 0 2px blue;float:none}.flex-container{display:flex}}.break{color:red}.foo{@media screen{color:red}@media print{color:red;color:red}}.break{color:red}.foo{@media screen{color:red}@media print{color:red}@media screen{color:red}}.break{color:red}.foo{color:red;@nest &>.bar{color:blue}@nest &>.baz{color:blue}}.break{color:red}@supports(flex-wrap:wrap){@media(min-width:50em){.foo{background:blue}}}.break{color:red}@supports(flex-wrap:wrap){.class,.class-1{color:red}}.break{color:red}@supports(flex-wrap:wrap){.class{color:red}}.break{color:red}.foo{@media(min-width:800px){& .bar,& .baz{color:red}}@supports(flex-wrap:wrap){& .class{color:red}}}.break{color:red}.class{color:red;&{color:red}}.break{color:red}@supports(display:flex){.class{display:flex}}@supports(display:grid){.class{display:flex}}.break{color:red}@media(min-width:200px){article{display:flex}}@media(min-width:600px){article{display:flex}}.break{color:red}@container my-layout (inline-size>45em){.foo{color:red;background:yellow}.bar{color:white}}.break{color:red}@layer foo{.foo{color:red;background:#fff}.baz{color:#fff}}.break,.foo,.bar{color:red}.foo{background:green}.break{color:red}.foo,.bar{background:red;color:green}.break{color:red}.foo,.bar{background:red;color:green}.break{color:red}.foo,.bar{background:red;color:green}.break{color:red}@media(hover){.foo{color:red;background:#fff}.baz{color:#fff}}.break{color:red}@supports(flex:1){.foo{color:red;background:#fff}.baz{color:#fff}}.break{color:red}.foo{& .foo,& .bar{background:red;color:green}}.break{color:red}.foo,.bar{background:red;color:green} +a,p{color:blue;font-weight:700}.break{color:red}h1,h2{color:red;line-height:1.5;font-size:2em}.break{color:red}h1{color:red;line-height:1.5;font-size:2em}h2{font-size:2em;color:red;line-height:1.5}.break{color:red}h1,h2,h3{color:red;line-height:1.5;font-size:2em}.break{color:red}h1,h2{color:red;line-height:1.5;font-size:2em}.break{color:red}h1{color:blue;font-weight:700}.break{color:red}h1{display:block;text-decoration:underline}.break{color:red}h1{color:red;display:block;text-decoration:underline}.break{color:red}h1{font-size:2em;color:#000;background:#fff;line-height:1.5}.break{color:red}@media print{h1{display:block;color:red}}.break{color:red}code::selection{background:red}code::-moz-selection{background:red}.break{color:red}.foo{&.bar{color:red}}.break{color:red}.foo{&.bar{color:red}}.break{color:red}.foo{@media screen{&.bar{color:red}}}.break{color:red}@media print{h1,p{display:block}}.break{color:red}@media print{h1{color:red;text-decoration:none}h2{text-decoration:none}}h3{text-decoration:none}.break{color:red}h3{text-decoration:none}@media print{h1{color:red;text-decoration:none}h2{text-decoration:none}}.break{color:red}@media screen and (max-width:480px){h1{display:block}}@media screen and (min-width:480px){h2{display:block}}.break{color:red}@media screen and (max-width:200px){h1{color:red}}@media screen and (min-width:480px){h1{display:block}}.break{color:red}@-webkit-keyframes test{0%{color:#000}to{color:#fff}}@keyframes test{0%{color:#000}to{color:#fff}}.break{color:red}h1{display:block}@media print{h1{color:red}}.break{color:red}@media print{h1{display:block}}h1,.break{color:red}h2{color:red;text-decoration:underline}.break,h1{color:red}h2{color:red;text-decoration:underline}h3{color:green;text-decoration:underline}.break{color:red}h1{color:red;text-decoration:underline}h2{text-decoration:underline;color:green}h3{font-weight:700;color:green}.break{color:red}.test0{color:red;border:none;margin:0}.test1{color:green;border:none;margin:0}.break{color:red}h1{color:red;font-weight:700}h2{font-weight:700}h3{text-decoration:none}.break{color:red}.test-1,.test-2{margin-top:10px}.another-test{margin-top:10px;margin-bottom:30px}.break{color:red}.test-1{margin-top:10px;margin-bottom:20px}.test-2{margin-top:10px}.another-test{margin-top:10px;margin-bottom:30px}.break{color:red}.foo{margin:0;display:block}.barim{display:block;line-height:1}.bazaz{font-size:3em;margin:0}.break{color:red}.foobam{font-family:serif;display:block}.barim{display:block;line-height:1}.bazaz{font-size:3em;font-family:serif}.break{color:red}.foo{font-family:serif;display:block}.barim{display:block;line-height:1}.bazaz{font-size:3em;font-family:serif}.break{color:red}h1{border:1px solid red;background-color:red;background-position:50%100%;border:1px solid red;background-color:red;border:1px solid red}.break{color:red}h1{color:black}h2,h3{color:black;font-weight:700}.break{color:red}.test0{color:red;border:none;margin:0}.longlonglonglong{color:green;border:none;margin:0}.break{color:red}code::-moz-selection{background:red}code::-moz-selection{background:red}.break{color:red}code:-ms-input-placeholder{background:red}code::-ms-input-placeholder{background:red}.break{color:red}input[type=range]{-webkit-appearance:none!important}input[type=range]::-webkit-slider-runnable-track{height:2px;width:100px;background:red;border:none}input[type=range]::-webkit-slider-thumb{-webkit-appearance:none!important;border:none;width:10px;height:10px;background:red}input[type=range]::-moz-range-thumb{border:none;width:10px;height:10px;background:red}.break{color:red}h1{color:red;text-align:right;text-decoration:underline}h2{text-align:right;text-decoration:underline}.break{color:red}h1{color:red;text-align:right;text-decoration:underline}h2{text-align:right;text-decoration:underline;color:green}.break{color:red}h1{background:white;color:red;text-align:right;text-decoration:underline}h2{text-align:right;text-decoration:underline;color:red}.break{color:red}h1{color:red;text-align:center;text-transform:small-caps}h2{text-align:center;color:red}.break{color:red}h1{text-align:left;text-transform:small-caps}h2{text-align:right;text-transform:small-caps}.break{color:red}@keyframes a{0%{transform-origin:right bottom;transform:rotate(-90deg);opacity:0}to{transform-origin:right bottom;transform:rotate(0);opacity:1}}.break{color:red}h2{margin-bottom:20px}h1{margin:10px;margin-bottom:20px}.break{color:red}h2{color:red;margin-bottom:20px}h1{color:red;margin:10px;margin-bottom:20px}.break{color:red}h2{margin:0;margin-bottom:20px}h1{margin:0;margin-top:20px}.break{color:red}h2{margin:0}h1{margin-top:20px;margin:0}.break{color:red}.box1{display:inline-block;display:block}.box2{display:inline-block}.break{color:red}h1,h2{display:block}.break{color:red}.a{-webkit-transform:translatex(-50%)translatey(-50%)rotate(270deg);-webkit-overflow-scrolling:touch}.b{-webkit-transform:translatex(-50%)translatey(-50%)rotate(270deg)}.break{color:red}h1,h2{display:block}.break{color:red}.one,.two,.three{font-family:"lorem";font-weight:400}.four{font-family:"lorem",serif;font-weight:400}.five{font-family:"lorem";font-weight:400}@font-face{font-family:"lorem";font-weight:400;src:url(/assets/lorem.eot);src:url(/assets/lorem.eot?#iefix)format("embedded-opentype"),url(/assets/lorem.woff)format("woff"),url(/assets/lorem.ttf)format("truetype")}.break{color:red}.foo{font-weight:400}.bar{font-family:"my-font";font-weight:400}@font-face{font-family:"my-font";font-weight:400;src:url(my-font.ttf)}.break{color:red}.a{font-family:Arial;font-family:Helvetica}.b{font-family:Arial}.break{color:red}.a{-webkit-transform:translatex(-50%)translatey(-50%)rotate(270deg);-webkit-overflow-scrolling:touch}.b{-webkit-transform:translatex(-50%)translatey(-50%)rotate(270deg)}.break{color:red}body{overflow:hidden;overflow-y:scroll;overflow-x:hidden}main{overflow:hidden}.break{color:red}.a{border-color:transparent;border-bottom-color:#111;border-bottom-style:solid}.b{border-color:transparent;border-bottom-color:#222;border-bottom-style:solid}.break{color:red}.fb-col-md-6{color:red;border-color:blue;flex:0 0 auto;flex-basis:50%}.fb-col-md-7{color:red;border-color:blue;flex:0 0 auto;flex-basis:58.3%}.break{color:red}.one{border:1px solid black;border-top:none}.two{border:1px solid black}.break{color:red}.dispendium-theme.fr-toolbar.fr-top{border-radius:0;background-clip:padding-box;box-shadow:none;border:1px solid#e0e0e0;border-bottom:0}.dispendium-theme.fr-toolbar.fr-bottom{border-radius:0;background-clip:padding-box;box-shadow:none;border:1px solid#e0e0e0;border-top:0}.break{color:red}.share .comment-count:before{content:" ";position:absolute;width:0;height:0;right:7px;top:26px;border:5px solid;border-color:#326891#326891 transparent transparent}.share .comment-count:after{content:" ";position:absolute;width:0;height:0;right:8px;top:24px;border:5px solid;border-color:#fff#fff transparent transparent}.break{color:red}@keyframes foo{0%{visibility:visible;transform:scale3d(.85,.85,.85);opacity:0}to{visibility:visible;opacity:1}}.break{color:red}.foo{background:#fff;-webkit-background-clip:text}.bar{background:#000;-webkit-background-clip:text}.break{color:red}.a{background-color:#fff;background-color:#717f83;color:#fff}.break{color:red}::placeholder{color:blue}h1{color:blue}.break{color:red}div,a~b{color:#fff}.break{color:red}div,a>b{color:#fff}.break{color:red}div,[href]{color:#fff}.break{color:red}div,[href=foo]{color:#fff}.break{color:red}div,[href~=foo]{color:#fff}.break{color:red}div,[href|=foo]{color:#fff}.break{color:red}div,[href^=foo]{color:#fff}.break{color:red}div,[href$=foo]{color:#fff}.break{color:red}div,[href*=foo]{color:#fff}.break{color:red}div{color:#fff}[href=foo i]{color:#fff}.break{color:red}:active{color:blue}h1{color:blue}.break{color:red}:after{color:blue}h1{color:blue}.break{color:red}:after{color:blue}h1{color:blue}.break{color:red}::placeholder{color:blue}h1{color:blue}.break{color:red}:host(tag){display:block}a{display:block}.break{color:red}p{color:blue}:unknown{color:blue}.break{color:red}p{color:blue}::unknown{color:blue}.break{color:red}@media print{h1{display:block;color:red}}.break{color:red}@media print{h1{display:block;color:red}}.break{color:red}@media(min-width:48rem){.wrapper{display:block}}@supports(display:flex){@media(min-width:48rem){.wrapper{display:flex}}}.break{color:red}@media print{h1{display:block;color:red}h2{padding:10px}}.break{color:red}@media print{h1{display:block;color:red}h2{padding:10px}}.break{color:red}@media(width:40px){.red{color:red}.green{color:green}.blue{color:blue}}@supports(--var:var){.white{color:white}.black{color:black}}.break{color:red}@media(width:40px){.red{color:red}.green{color:green}.blue{color:blue}}@supports(--var:var){@media(width:40px){.white{color:white}.black{color:black}}}.break{color:red}@media print{h1{display:block}}@media screen{h1{color:red}h2{padding:10px}}.break{color:red}@media(min-width:48rem){.wrapper{display:block}}@supports(display:flex){@media(min-width:48rem){.wrapper{display:flex}}}.break{color:red}@media print{h1{display:block}}@supports(color:red){@media print and (color:1){h1{color:red}h2{padding:10px}}}.break{color:red}@media(width:40px){h1{border:1px solid red;background-color:red;background-position:50%100%;border:1px solid red;background-color:red;border:1px solid red}}.break{color:red}@media(width:40px){h1{color:black}h2,h3{color:black;font-weight:700}}.break{color:red}.a{color:red;display:flex;font-size:10px}.c{all:unset;color:red;display:flex;font-size:10px}.break,.foo{color:red}.bar{all:unset;color:red}.break{color:red}.a{color:red;display:flex;font-size:10px;direction:tlr}.c{all:unset;color:red;display:flex;font-size:10px;direction:tlr}.break{color:red}a{color:green}a:focus-visible{color:green}a:focus-visible{background:red}.break{color:red}a,a:link{color:#555}a:visited{color:#555}.break{color:red}h1{color:#001;color:#002;color:#003}h2{color:#001;color:#002}.break{color:red}.foo,.bar{@media screen{color:red}}.break{color:red}.foo{@media screen{color:red}}.break{color:red}.foo{@media screen{color:red}@media print{color:red}}.break{color:red}@supports(display:flex){.flex-container>*{text-shadow:0 0 2px blue;float:none}.flex-container{display:flex}}.break{color:red}.foo{@media screen{color:red}@media print{color:red}}.break{color:red}.foo{@media screen{color:red}@media print{color:red}@media screen{color:red}}.break{color:red}.foo{color:red;@nest &>.bar{color:blue}@nest &>.baz{color:blue}}.break{color:red}@supports(flex-wrap:wrap){@media(min-width:50em){.foo{background:blue}}}.break{color:red}@supports(flex-wrap:wrap){.class,.class-1{color:red}}.break{color:red}@supports(flex-wrap:wrap){.class{color:red}}.break{color:red}.foo{@media(min-width:800px){& .bar,& .baz{color:red}}@supports(flex-wrap:wrap){& .class{color:red}}}.break{color:red}.class{color:red;&{color:red}}.break{color:red}@supports(display:flex){.class{display:flex}}@supports(display:grid){.class{display:flex}}.break{color:red}@media(min-width:200px){article{display:flex}}@media(min-width:600px){article{display:flex}}.break{color:red}@container my-layout (inline-size>45em){.foo{color:red;background:yellow}.bar{color:white}}.break{color:red}@layer foo{.foo{color:red;background:#fff}.baz{color:#fff}}.break,.foo,.bar{color:red}.foo{background:green}.break{color:red}.foo,.bar{background:red;color:green}.break{color:red}.foo,.bar{background:red;color:green}.break{color:red}.foo,.bar{background:red;color:green}.break{color:red}@media(hover){.foo{color:red;background:#fff}.baz{color:#fff}}.break{color:red}@supports(flex:1){.foo{color:red;background:#fff}.baz{color:#fff}}.break{color:red}.foo{& .foo,& .bar{background:red;color:green}}.break{color:red}.foo,.bar{background:red;color:green} diff --git a/crates/swc_css_minifier/tests/fixture/compress_angle/output.min.css b/crates/swc_css_minifier/tests/fixture/compress_angle/output.min.css index 8d657495449..8f8ba42ef95 100644 --- a/crates/swc_css_minifier/tests/fixture/compress_angle/output.min.css +++ b/crates/swc_css_minifier/tests/fixture/compress_angle/output.min.css @@ -1 +1 @@ -.deg{transform:rotate(0);transform:rotate(0);transform:rotate(9deg);transform:rotate(-9deg);transform:rotate(10deg);transform:rotate(180deg);transform:rotate(180deg);transform:rotate(0);transform:rotate(0);transform:rotate(350deg);transform:rotate(-9deg);transform:rotate(0);transform:rotate(360.5deg);transform:rotate(-360.5deg);transform:rotate(1deg);transform:rotate(-1deg)}.grad{transform:rotate(0);transform:rotate(0);transform:rotate(9grad);transform:rotate(-9grad);transform:rotate(9deg);transform:rotate(180deg);transform:rotate(180deg);transform:rotate(0);transform:rotate(0);transform:rotate(0);transform:rotate(0);transform:rotate(0);transform:rotate(800.5grad);transform:rotate(-800.5grad);transform:rotate(821grad);transform:rotate(-821grad)}.rad{transform:rotate(0);transform:rotate(0);transform:rotate(1rad);transform:rotate(1.5rad);transform:rotate(-1.5rad)}.turn{transform:rotate(0);transform:rotate(0);transform:rotate(180deg);transform:rotate(180deg);transform:rotate(0);transform:rotate(0);transform:rotate(180deg);transform:rotate(0);transform:rotate(180deg);transform:rotate(0)}.cross{transform:rotate(90deg);transform:rotate(90deg);transform:rotate(90deg);transform:rotate(1.57rad);transform:rotate(3.1416rad)}.class1{transform:rotate(0)}.class2{transform:skew(0,0)}.class3{transform:skewx(0)}.class4{transform:skewy(0)}.class5{transform:rotate3d(10,10,10,0)}.class6{transform:rotatex(0)}.class7{transform:rotatey(0)}.class8{transform:rotate(0)}.class9,.class10{transform:rotate(0)}.class11{transform:rotate(0)}@keyframes spinner-border{to{transform:rotate(360deg)}} +.deg{transform:rotate(0);transform:rotate(9deg);transform:rotate(-9deg);transform:rotate(10deg);transform:rotate(180deg);transform:rotate(0);transform:rotate(350deg);transform:rotate(-9deg);transform:rotate(0);transform:rotate(360.5deg);transform:rotate(-360.5deg);transform:rotate(1deg);transform:rotate(-1deg)}.grad{transform:rotate(0);transform:rotate(9grad);transform:rotate(-9grad);transform:rotate(9deg);transform:rotate(180deg);transform:rotate(0);transform:rotate(800.5grad);transform:rotate(-800.5grad);transform:rotate(821grad);transform:rotate(-821grad)}.rad{transform:rotate(0);transform:rotate(1rad);transform:rotate(1.5rad);transform:rotate(-1.5rad)}.turn{transform:rotate(0);transform:rotate(180deg);transform:rotate(0);transform:rotate(180deg);transform:rotate(0);transform:rotate(180deg);transform:rotate(0)}.cross{transform:rotate(90deg);transform:rotate(1.57rad);transform:rotate(3.1416rad)}.class1{transform:rotate(0)}.class2{transform:skew(0,0)}.class3{transform:skewx(0)}.class4{transform:skewy(0)}.class5{transform:rotate3d(10,10,10,0)}.class6{transform:rotatex(0)}.class7{transform:rotatey(0)}.class8{transform:rotate(0)}.class9,.class10{transform:rotate(0)}.class11{transform:rotate(0)}@keyframes spinner-border{to{transform:rotate(360deg)}} diff --git a/crates/swc_css_minifier/tests/fixture/compress_time/output.min.css b/crates/swc_css_minifier/tests/fixture/compress_time/output.min.css index a75cdc660e7..6f4510fb80d 100644 --- a/crates/swc_css_minifier/tests/fixture/compress_time/output.min.css +++ b/crates/swc_css_minifier/tests/fixture/compress_time/output.min.css @@ -1 +1 @@ -div{transition-duration:0s;transition-duration:0s;transition-duration:1ms;transition-duration:10ms;transition-duration:.1s;transition-duration:.101s;transition-duration:.5s;transition-duration:.5s;transition-duration:.999s;transition-duration:1s;transition-duration:9.999s;transition-duration:10s;transition-duration:50s;transition-duration:50.005s;transition-duration:0s;transition-duration:0s;transition-duration:1s;transition-duration:10s;transition-duration:100s;transition-duration:1e3s;transition-duration:1e4s;transition-duration:5e4s;transition-duration:50005s;transition-duration:1ms;transition-duration:1ms;transition-duration:5ms;transition-duration:50ms;transition-duration:50ms;transition-duration:.5s;transition-duration:.543s;transition-duration:.1s;transition-duration:10ms;transition-duration:.32s;transition-duration:75ms;transition-duration:.075ms} +div{transition-duration:0s;transition-duration:1ms;transition-duration:10ms;transition-duration:.1s;transition-duration:.101s;transition-duration:.5s;transition-duration:.999s;transition-duration:1s;transition-duration:9.999s;transition-duration:10s;transition-duration:50s;transition-duration:50.005s;transition-duration:0s;transition-duration:1s;transition-duration:10s;transition-duration:100s;transition-duration:1e3s;transition-duration:1e4s;transition-duration:5e4s;transition-duration:50005s;transition-duration:1ms;transition-duration:5ms;transition-duration:50ms;transition-duration:.5s;transition-duration:.543s;transition-duration:.1s;transition-duration:10ms;transition-duration:.32s;transition-duration:75ms;transition-duration:.075ms}