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 Modules - class names not mangled in @scope rule #18597

Closed
7 tasks done
mrginglymus opened this issue Nov 6, 2024 · 1 comment · Fixed by #18598
Closed
7 tasks done

CSS Modules - class names not mangled in @scope rule #18597

mrginglymus opened this issue Nov 6, 2024 · 1 comment · Fixed by #18598
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

@mrginglymus
Copy link
Contributor

Describe the bug

In a css modules file, for an input of

@scope (.foo) {
  .bar {
    color: blue;
  }
}

I expect an output of (e.g.)

@scope (.EgL3uq_foo) {
  .EgL3uq_bar {
    color: blue;
  }
}

Both lightningcss and postcss, used via their respective apis directly, do this transform correclty.

However, vite does not mangle the class name selector in the @scope at-rule, resulting in:

@scope (.foo) {
  ._bar_16phc_6 {
    color: blue;
  }
}

Reproduction

https://stackblitz.com/edit/vitejs-vite-xyfgcb?file=main.js,index.html,style.module.css&terminal=dev

Steps to reproduce

No response

System Info

See stackblitz

Used Package Manager

npm

Logs

No response

Validations

@mrginglymus
Copy link
Contributor Author

Further investigation suggests that css-modules/postcss-modules-local-by-default#71 fixes this, released in 4.0.4. I will attempt to raise a PR updating it.

@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) labels Nov 8, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Nov 23, 2024
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