lightningcss icon indicating copy to clipboard operation
lightningcss copied to clipboard

Inconsistent CSS variables rules optimization

Open scebotari66 opened this issue 2 years ago • 1 comments

Given the following CSS:

.foo {
  color: red;
  color: var(--my-red);
  background-color: blue;
  background-color: var(--my-blue);
}

I get this output:

.foo {
  color: var(--my-red);
  background-color: #00f;
  background-color: var(--my-blue);
}

I would also expect only the CSS variables background-color rule version to be kept, like it is the case with color. Is this a bug?

scebotari66 avatar Sep 04 '23 06:09 scebotari66

Yeah we could probably make this line conditional depending what other background-related properties have been seen. https://github.com/parcel-bundler/lightningcss/blob/9b3e6f425b1132243930737f306cb864b7b892d0/src/properties/background.rs#L897

devongovett avatar Oct 09 '23 05:10 devongovett