vitejs / vite

Next generation frontend tooling. It's fast!
http://vite.dev
MIT License
68.75k stars 6.21k forks source link

Minified pseudoselectors are not spec-compliant, breaking Qwik #11808

Closed cmbartschat closed 1 year ago

cmbartschat commented 1 year ago

Describe the bug

span::before {
  content: '';
}

Becomes:

span:before{content:""}

By dropping the extra : from ::before, this is against the spec depended on by a plugin used by the Qwik build, see issue: https://github.com/BuilderIO/qwik/issues/2189

Reproduction

https://stackblitz.com/edit/vitejs-vite-hwufm4?file=style.css

Steps to reproduce

Run npm run build, then inspect the dist/assets/index-xxx.css to see the output.

System Info

Stackblitz/Firefox/Windows

Used Package Manager

npm

Logs

No response

Validations

sapphi-red commented 1 year ago

Vite uses esbuild to minify CSS and esbuild transforms

span.foo::before {
  content: '';
}

into

span.foo:before{content:""}

repl

But I think changing ::before to :before is spec-compliant. This is written on the spec.

For compatibility with existing style sheets written against CSS Level 2 [CSS2], user agents must also accept the previous one-colon notation (:before, :after, :first-letter, :first-line) for the ::before, ::after, ::first-letter, and ::first-line pseudo-elements. https://w3c.github.io/csswg-drafts/css-pseudo/#css2-compat

I guess qwik's transformation doesn't take pseudo elements with one-colon notation like :before into account.