matthiasmullie / minify

CSS & JavaScript minifier, in PHP. Removes whitespace, strips comments, combines files (incl. @import statements and small assets in CSS files), and optimizes/shortens a few common programming patterns.
https://matthiasmullie.github.io/minify/
MIT License
1.96k stars 310 forks source link

CSS variable with leading whitespaces 0px should not be minified to 0 #378

Closed Cacodaimon closed 2 years ago

Cacodaimon commented 3 years ago

A CSS variable with leading white spaces and 0px gets minified to 0, happens e.g. with https://tailwindcss.com/docs/ring-offset-width and leads to an CSS calc issue.

Example:

https://github.com/matthiasmullie/minify/compare/0cf6c085b1dde107e375a5938e2e5033640de0e0...Cacodaimon:master

:root {
  --some-var: 0px;
}
p {
margin-left: calc(20px + var(--some-var));
}

Gets minifed to:

:root{--some-var:0}.some-class{margin-left:calc(20px + var(--some-var))}

Related: https://github.com/matthiasmullie/minify/issues/298

muster-mark commented 2 years ago

This broke our buttons. Imagine this is just a case of not performing this particular optimisation on css variables.