-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
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
Inconsistent compilation of CSS Modules between dev and build commands when using ?url query param #13416
Comments
|
Seems like vite has to transform css contents before they are emitted 🤔 vite/packages/vite/src/node/plugins/asset.ts Lines 357 to 362 in 168e1fc
|
The weird thing is that it works in dev, so it is a different "asset" treatment. |
I am experiencing the same issue with css file url. In DEV mode tailwind (postcss) processing of the file is working fine, but not when built. new URL('./styles.css', import.meta.url).href |
We're running into this issue in the context of Remix + Vite because the I think we'll recommend that people avoid using |
Any chance the inconsistencies will be fixed before v5 release? |
No, this won't be included in 5.0.0. We discussed in the last meeting about this and decided to go with #2522 (comment). |
Describe the bug
Hi everyone 👋
I'm trying to workaround #13401 by manually listing CSS Modules I want to manipulate on the client-side but the contents of the transformed asset differs between
vite dev
andvite build
, to be more specific, indev
the CSS class names are property hashed as I would expect for a.module.css
file but they are not aftervite build
.For the reproduction project, I have an
Isolated.module.css
file:Which I'm importing as follows:
Then I'm logging the URL string, fetching such file, and redering its contents on the page:
Reproduction
https://stackblitz.com/edit/vitejs-vite-pj3wxw?file=main.js
Steps to reproduce
Open the reproduction project.
You will see the content of the CSS Module on the page. CSS Class Names will be hashed, e.g.:
Open a new Terminal in the StackBlitz UI and run the preview script:
It will compile and serve the compiled project on port
4173
and StackBlitz should replace the browser view on the right side to point to the new port automatically.On the new page you will see that the CSS Class Names are not hashed, e.g.:
System Info
System: OS: Linux 5.0 undefined CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz Memory: 0 Bytes / 0 Bytes Shell: 1.0 - /bin/jsh Binaries: Node: 16.14.2 - /usr/local/bin/node Yarn: 1.22.19 - /usr/local/bin/yarn npm: 7.17.0 - /usr/local/bin/npm npmPackages: vite: ^4.3.9 => 4.3.9
Used Package Manager
npm
Logs
Validations
The text was updated successfully, but these errors were encountered: