bug: Wrongly generated CSS selector upon build, while dev works fine #15912
Labels
bug: upstream
Bug in a dependency of Vite
has workaround
p2-edge-case
Bug, but has workaround or limited in scope (priority)
Describe the bug
Hello!
In a React TS + Vite project using CSS modules, I stumbled upon an issue
where all written css selectors are correctly applied to the elements in dev mode,
but in the production build, one selector is missing, and - upon further inspection - the generated CSS
differs slightly.
It happens roughly like this:
The following [here simplified] CSS is what I've written in the CSS module, and is used as-is in dev mode and works fine:
However, in production, the last css selector ( &:after, & .input ) is wrongly compiled into the following:
The .inputContainer:after selector is removed, and instead it compiles to two times the same selector.
Reproduction
https://stackblitz.com/edit/vitejs-vite-k6n2wy?file=src%2FApp.module.css
Steps to reproduce
I've attached a reproduction url using the stock React+Vite template (skipping TS here, it doesnt matter).
If you run that one in stackblitz as is, both .input and the :after Element will be laid on top of each other, which is correct.
However, if you stop that server in the terminal, run
npm run build
and thennpx serve dist
, you will see that they are not on top of another anymore, since the :after Element is missing a css rule, due to the css being wrongly compiled.System Info
Used Package Manager
npm
Logs
No response
Validations
The text was updated successfully, but these errors were encountered: