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

Non deterministic build with cssCodeSplit = false and css imports #16582

Closed
7 tasks done
susnux opened this issue May 3, 2024 · 1 comment · Fixed by #16078
Closed
7 tasks done

Non deterministic build with cssCodeSplit = false and css imports #16582

susnux opened this issue May 3, 2024 · 1 comment · Fixed by #16078

Comments

@susnux
Copy link
Contributor

susnux commented May 3, 2024

Describe the bug

If I set cssCodeSplit to false and have css files imported this leads to empty chunks named like style-xyz, but the name is changing on every vite build without changed source.
Due to the changed name all files that imported that style are now also changing (as the import name changes, the content is different thus the hash is different, causing the file to rename).

Reproduction

https://stackblitz.com/edit/vitejs-vite-kkmede

Steps to reproduce

I could currently not reproduce the non-deterministic behavior (my setup is much more complex with plugins), but on the reproduction you can see an empty chunk is emitted for the style import.

  1. run npx vite build
  2. see empty chunk that contained the styles once

System Info

System:
    OS: Linux 6.8 openSUSE Tumbleweed 20240429
    CPU: (12) x64 AMD Ryzen 5 5500U with Radeon Graphics
    Memory: 3.93 GB / 14.98 GB
    Container: Yes
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.12.1 - /usr/bin/node
    Yarn: 1.22.21 - /usr/bin/yarn
    npm: 10.5.0 - /usr/bin/npm
  Browsers:
    Chromium: 122.0.6261.128
  npmPackages:
    vite: ^5.2.11 => 5.2.11

Used Package Manager

npm

Logs

No response

Validations

Copy link

stackblitz bot commented May 3, 2024

Fix this issue in StackBlitz Codeflow Start a new pull request in StackBlitz Codeflow.

susnux added a commit to susnux/vite that referenced this issue May 3, 2024
Resolves vitejs#16582

When setting `cssCodeSplit: false` the styles are still split into one style file.
But currently the imported CSS results in empty chunks,
as in the current implementation empty chunks are only removed when `cssCodeSplit` was set to `true`.
So this also adds empty style chunks to `pureCSSChunks` even with `cssCodeSplit: false`.

Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
susnux added a commit to susnux/vite that referenced this issue May 3, 2024
Resolves vitejs#16582

When setting `cssCodeSplit: false` the styles are still split into one style file.
But currently the imported CSS results in empty chunks,
as in the current implementation empty chunks are only removed when `cssCodeSplit` was set to `true`.
So this also adds empty style chunks to `pureCSSChunks` even with `cssCodeSplit: false`.

Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
susnux added a commit to susnux/vite that referenced this issue May 3, 2024
Resolves vitejs#16582

When setting `cssCodeSplit: false` the styles are still split into one style file.
But currently the imported CSS results in empty chunks,
as in the current implementation empty chunks are only removed when `cssCodeSplit` was set to `true`.
So this also adds empty style chunks to `pureCSSChunks` even with `cssCodeSplit: false`.

Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
susnux added a commit to susnux/vite that referenced this issue May 3, 2024
Resolves vitejs#16582

When setting `cssCodeSplit: false` the styles are still split into one style file.
But currently the imported CSS results in empty chunks,
as in the current implementation empty chunks are only removed when `cssCodeSplit` was set to `true`.
So this also adds empty style chunks to `pureCSSChunks` even with `cssCodeSplit: false`.

Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant