Describe the bug
Browser native CSS nesting should be flattened based on the Vite default build.target, but is not.
Reproduction
Vanilla Vite project correctly builds the following CSS:
import './style.css';
document.querySelector<HTMLDivElement>('#app')!.innerHTML = `<span>Hello, </span>`;
/* Nesting requires Chrome 120, Safari 17.2 */
/* Reference https://caniuse.com/css-nesting */
span {
color: red;
&::after {
content: 'World!';
}
}
/* Default option (targeting Safari 14) */
span{color:red}span:after{content:"World!"}
/* With build: { cssTarget: 'safari17.2' } */
span{color:red;&:after{content:"World!"}}
This is not the case with a SvelteKit template:
┌ Welcome to the Svelte CLI! (v0.8.1)
│
◇ Which template would you like?
│ SvelteKit minimal
│
◇ Add type checking with TypeScript?
│ Yes, using TypeScript syntax
│
◆ Project created
│
◇ What would you like to add to your project? (use arrow keys / space bar)
│ none
<!-- src\routes\+page.svelte -->
<span>Hello, </span>
<style>
span {
color: red;
&::after {
content: 'World!';
}
}
</style>
/* .svelte-kit\output\client\_app\immutable\assets\_page.CmDdIB0i.css */
/* With build: { cssTarget: 'safari14' } */
span.svelte-yc2s4t{color:red}span.svelte-yc2s4t:after{content:"World!"}
/* .svelte-kit\output\client\_app\immutable\assets\_page.D4Ercq9S.css */
/* Default option (targeting Safari 14) */
span.svelte-yc2s4t{color:red;&:after{content:"World!"}}
Logs
System Info
System:
OS: Windows 11 10.0.26100
CPU: (8) x64 Intel(R) Core(TM) Ultra 7 258V
Memory: 9.22 GB / 31.51 GB
Binaries:
Node: 22.14.0 - ~\AppData\Local\fnm_multishells\12668_1745374883481\node.EXE
npm: 10.9.2 - ~\AppData\Local\fnm_multishells\12668_1745374883481\npm.CMD
pnpm: 10.9.0 - ~\AppData\Local\fnm_multishells\12668_1745374883481\pnpm.CMD
Browsers:
Edge: Chromium (131.0.2903.112)
npmPackages:
@sveltejs/adapter-auto: ^4.0.0 => 4.0.0
@sveltejs/kit: ^2.16.0 => 2.20.7
@sveltejs/vite-plugin-svelte: ^5.0.0 => 5.0.3
svelte: ^5.0.0 => 5.28.2
vite: ^6.2.5 => 6.3.2
Severity
serious, but I can work around it
Additional Information
No response
Describe the bug
Browser native CSS nesting should be flattened based on the Vite default
build.target, but is not.Reproduction
Vanilla Vite project correctly builds the following CSS:
This is not the case with a SvelteKit template:
Logs
System Info
Severity
serious, but I can work around it
Additional Information
No response