-
-
Notifications
You must be signed in to change notification settings - Fork 7.2k
Open
Labels
Description
Describe the bug
The value of cssTarget
should be consistent between client and server.
But that isn't the case, for example with following config:
// vite.config.js
export default {
environments: {
ssr: {
build: {
target: 'es2022'
}
}
}
}
The value of config.build.cssTarget
differs between:
- Client-side:
es2022
- Server-side:
[ 'chrome107', 'edge107', 'firefox104', 'safari16' ]
I believe changing ssr.build.target
shouldn't also change cssTarget
.
One issue is that it leads to CSS duplication when frameworks try to dedupe the CSS generated redundantly between client and server. Example with Vike: vikejs/vike#1815 (comment).
Another example of why this is an issue: @cloudfalre/vite-plugin
sets ssr.build.target
to es2022
which makes sense (the server code targets Cloudflare's workerd
runtime), but it doesn't make sense that it also changes cssTarget
.
Reproduction
https://github.com/brillout/repro_vite-css-duplication
Steps to reproduce
No response
System Info
System:
OS: Linux 6.8 Ubuntu 24.04.2 LTS 24.04.2 LTS (Noble Numbat)
CPU: (8) x64 Intel(R) Core(TM) i5-8250U CPU @ 1.60GHz
Memory: 3.29 GB / 7.52 GB
Container: Yes
Shell: 5.2.21 - /bin/bash
Binaries:
Node: 22.14.0 - ~/.nvm/versions/node/v22.14.0/bin/node
Yarn: 1.22.22 - ~/.nix-profile/bin/yarn
npm: 10.9.2 - ~/.nvm/versions/node/v22.14.0/bin/npm
pnpm: 9.15.9 - ~/.local/share/pnpm/pnpm
bun: 1.1.24 - ~/.bun/bin/bun
Watchman: 2024.03.11.00 - /home/rom/.nix-profile/bin/watchman
Browsers:
Chrome: 138.0.7204.168
npmPackages:
@vitejs/plugin-react: ^4.6.0 => 4.7.0
vite: ^7.0.0 => 7.0.6
Used Package Manager
pnpm
Logs
No response
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Make sure this is a Vite issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to vuejs/core instead.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.