-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
[v4] Vite plugin providing a virtual file can't be resolved from within main CSS file #15047
Comments
From digging through the source code a bit, it seems that the module resolution is actually done by this bit - if I understand correctly: tailwindcss/packages/@tailwindcss-node/src/compile.ts Lines 201 to 212 in 7b19b00
Does that mean, custom virtual modules are not supported in CSS files? |
Hey! @spaceemotion. Yeah that's right we don't consult the Vite module resolution when resolving imports right now. Two things you can try to work around it:
I agree with you that this is unexpected though and that the Vite plugin should use the Vite module resolution system and not a custom one. |
The SVG-Core version of FontAwesome does not provide a static CSS, as they generate it on the fly based on the config. They usually add the styles when FontAwesome loads, but since we want to build a (mostly) static site, this means that icons would look weird if the JavaScript hasn't loaded yet. For the time being I had it generate a static version, and "hard-coded" an import to that one. Not ideal, but... Thanks for the tip with the postcss alternative, but I think the current workaround will work until the vite plugin supports the additional module resolution :) |
What version of Tailwind CSS are you using?
What build tool (or framework if it abstracts the build tool) are you using?
astro 5.0.0-beta.8
, usingvite 6.0.0-beta.10
What version of Node.js are you using?
v20
What browser are you using?
Chrome/Edge/Brave
What operating system are you using?
Linux/Windows
Reproduction URL
We got the following stylesheet:
The custom vite plugin is quite simple:
We need the fontawesome CSS to be included in the base layer of our CSS, since we want to be able to overwrite some things (like icon size) via the utility classes. We also don't want to include the CSS on every page, and instead have it in the global stylesheet.
Sadly, FontAwesome does not offer a simple static CSS we can use, since the classes are built at run-/build-time.
Describe your issue
I ran
astro dev
with verbose enabled:From what I can tell, the resolving is being handled by tailwind, and not Astro/Vite? I tried to see if there is a way to still make this worth, but not sure why the virtual module isn't being picked up - the same approach (using virtual modules) works without issue in other parts of the pipeline where we just import things into Vue/Astro/JS.
https://stackblitz.com/edit/vite-u8kysb?file=vite.config.mjs (doesn't load inside of stackblitz due to oxide, but has a minimal example)
The text was updated successfully, but these errors were encountered: