lightningcss icon indicating copy to clipboard operation
lightningcss copied to clipboard

[bug]lighting css will shuffle css properties order

Open sbyps opened this issue 1 year ago • 2 comments

img_v3_02e8_5f9d4970-3d6e-4ccf-8b7f-f25f0f7f5b0g img_v3_02e8_44f16586-43a8-4f71-8975-a1dc5f0c19bg

sbyps avatar Sep 01 '24 05:09 sbyps

The same thing happened to us as well. height:auto was ordered after height:calc(...) after minimization instead of before. (height:auto shouldn't have been there in the first place, but the change was definitely unexpected.)

matthiask avatar Sep 18 '24 11:09 matthiask

Here's a minimal example showing the breakage:

import fs from "node:fs";
import { transform } from 'lightningcss';

let style = `
.navigation {
    height: auto;
    height: calc(100vh - var(--header-height, 0rem));
}
`

let { code, map } = transform({
  filename: 'style.css',
  code: Buffer.from(style),
  minify: true,
  sourceMap: true
});

fs.writeFileSync(1, code);
console.log()

See:

$ node minify.mjs 
.navigation{height:calc(100vh - var(--header-height,0rem));height:auto}
$

The height:auto now overrides the calc() value instead of being overridden by it.

matthiask avatar Sep 18 '24 11:09 matthiask