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

Using generateScopedName with vite.css.modules breaks CSS, even if classes are correctly outputted #5097

Closed
1 task
JulianCataldo opened this issue Oct 15, 2022 · 2 comments · Fixed by vitejs/vite#10514
Assignees
Labels
- P3: minor bug An edge case that only affects very specific usage (priority)

Comments

@JulianCataldo
Copy link

JulianCataldo commented Oct 15, 2022

What version of astro are you using?

latest (stackblitz starter)

Are you using an SSR adapter? If so, which one?

none

What package manager are you using?

npm

What operating system are you using?

macOS

Describe the Bug

Adding this to the stackblitz starter:

import { defineConfig } from 'astro/config';

// https://astro.build/config
export default defineConfig({
  vite: {
    css: {
      modules: {
        generateScopedName: 'custom__[hash:base64:5]',
      },
    },
  },
});

We get the new classes:

<h1 class="custom__TuMzL astro-JCQVOAF3">
	HELLO, this should be red

...
</h1>

But CSS isn't correctly associated anymore, it looks like it is just not inserted in the <head/> at all.

remove generateScopedName, and everything get back to normal, the text is red.

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-wdlcyk-khanxf?file=src/components/Card.astro

Participation

  • I am willing to submit a pull request for this issue.
@bluwy
Copy link
Member

bluwy commented Oct 18, 2022

vitejs/vite#10514 should fix this. It's an inconsistency between client and server transformations of the CSS module, since [hash:base64:5] uses the filename to hash too.

@bluwy bluwy added the - P3: minor bug An edge case that only affects very specific usage (priority) label Oct 18, 2022
@bluwy
Copy link
Member

bluwy commented Oct 20, 2022

Closing as vitejs/vite#10514 is merged. The fix should be brought upstream when we update to Vite 3.2

@bluwy bluwy closed this as completed Oct 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
- 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