Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CSS variables with same value defined in media query are merged incorrectly #11704

Closed
7 tasks done
CLDXiang opened this issue Jan 16, 2023 · 3 comments · Fixed by #11908
Closed
7 tasks done

CSS variables with same value defined in media query are merged incorrectly #11704

CLDXiang opened this issue Jan 16, 2023 · 3 comments · Fixed by #11908
Labels
bug: upstream Bug in a dependency of Vite feat: css p3-minor-bug An edge case that only affects very specific usage (priority)

Comments

@CLDXiang
Copy link

Describe the bug

When I define two different CSS variables with same value in media query, only one of these CSS variables will remain in the building result.

e.g.

@media (prefers-color-scheme: dark) {
  body {
    --VAR-1: #000;
  }
}

@media (prefers-color-scheme: dark) {
  body {
    --VAR-2: #000;
  }
}

building output:

@media (prefers-color-scheme: dark){body{--VAR-2: #000}}

Reproduction

https://github.com/CLDXiang/vite-css-var-in-media-merge-bug

Steps to reproduce

No response

System Info

System:
    OS: macOS 12.5.1
    CPU: (20) x64 Intel(R) Core(TM) i9-10910 CPU @ 3.60GHz
    Memory: 2.07 GB / 32.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 16.15.1 - ~/.nvm/versions/node/v16.15.1/bin/node
    Yarn: 1.22.17 - ~/.yarn/bin/yarn
    npm: 8.11.0 - ~/.nvm/versions/node/v16.15.1/bin/npm
  Browsers:
    Chrome: 108.0.5359.124
    Firefox: 100.0.2
    Safari: 15.6.1
  npmPackages:
    vite: ^4.0.0 => 4.0.4

Used Package Manager

yarn

Logs

No response

Validations

@CLDXiang
Copy link
Author

CLDXiang commented Jan 16, 2023

Seems caused by esbuild's minify at this line.

Run esbuild --bundle style.css --outfile=out.css --minify will produce this bug, so it's actually an esbuild bug. Will vite handle this on its own or report this to esbuild?

@sapphi-red
Copy link
Member

@CLDXiang Thanks for digging down! Would you report this to esbuild?

@sapphi-red sapphi-red added bug: upstream Bug in a dependency of Vite feat: css p3-minor-bug An edge case that only affects very specific usage (priority) and removed pending triage labels Jan 17, 2023
@CLDXiang
Copy link
Author

@sapphi-red ok. evanw/esbuild#2838

@sapphi-red sapphi-red mentioned this issue Feb 2, 2023
9 tasks
@github-actions github-actions bot locked and limited conversation to collaborators Mar 9, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug: upstream Bug in a dependency of Vite feat: css p3-minor-bug An edge case that only affects very specific usage (priority)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants