You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Not sure if this is the right spot to report, but since the error window mentions this plugin specifically, figured I'd start here.
Anyways, not sure if I'm doing something wrong but in the current stable version of Svelte, the following component compiles and functions as expected
<h1>Welcome to SvelteKit</h1>
<p>Visit <ahref="https://kit.svelte.dev">kit.svelte.dev</a> to read the documentation</p>
<style>
h1 { &:hover {color:red; } }
</style>
However in the current Svelte 5 beta, an error is triggered saying Expected a valid CSS identifier. This is tested from a fresh install of SvelteKit running
npm create svelte@latest
afterwards running
npm install svelte@next
to install Svelte 5
Not sure how support was implemented in Svelte 4 but it'd be great to have this working in the final release without having to download another package.
Svelte 5 should already be setup in package.json so error should pop up immediately
Rerun npm i svelte@latest to compare and contrast.
Logs
[plugin:vite-plugin-svelte] C:/Users/Joseph/Documents/projects/tests/svelte-test/src/routes/+page.svelte:9:1 Expected a valid CSS identifier
C:/Users/Joseph/Documents/projects/tests/svelte-test/src/routes/+page.svelte:9:1
7 | color:red;
8 | }
9 | }
| ^
10 |</style>
CompileError: Expected a valid CSS identifier
at error (file:///C:/Users/Joseph/Documents/projects/tests/svelte-test/node_modules/svelte/src/compiler/errors.js:568:8)
at read_identifier (file:///C:/Users/Joseph/Documents/projects/tests/svelte-test/node_modules/svelte/src/compiler/phases/1-parse/read/style.js:491:3)
at read_selector (file:///C:/Users/Joseph/Documents/projects/tests/svelte-test/node_modules/svelte/src/compiler/phases/1-parse/read/style.js:289:11)
at read_selector_list (file:///C:/Users/Joseph/Documents/projects/tests/svelte-test/node_modules/svelte/src/compiler/phases/1-parse/read/style.js:157:17)
at read_rule (file:///C:/Users/Joseph/Documents/projects/tests/svelte-test/node_modules/svelte/src/compiler/phases/1-parse/read/style.js:139:12)
at read_body (file:///C:/Users/Joseph/Documents/projects/tests/svelte-test/node_modules/svelte/src/compiler/phases/1-parse/read/style.js:64:18)
at read_style (file:///C:/Users/Joseph/Documents/projects/tests/svelte-test/node_modules/svelte/src/compiler/phases/1-parse/read/style.js:25:19)
at tag (file:///C:/Users/Joseph/Documents/projects/tests/svelte-test/node_modules/svelte/src/compiler/phases/1-parse/state/element.js:264:20)
at new Parser (file:///C:/Users/Joseph/Documents/projects/tests/svelte-test/node_modules/svelte/src/compiler/phases/1-parse/index.js:65:12)
at parse (file:///C:/Users/Joseph/Documents/projects/tests/svelte-test/node_modules/svelte/src/compiler/ph
native css nesting isn't supported in svelte4 by itself, some parts of it work but thats because svelte4 uses css-tree. svelte5 does not and hasn't implemented native css nesting yet.
To work around this, use a preprocessor that converts nested syntax to unnested. This can be done with postcss or lightningcss (experimental option on vite)
Describe the bug
Not sure if this is the right spot to report, but since the error window mentions this plugin specifically, figured I'd start here.
Anyways, not sure if I'm doing something wrong but in the current stable version of Svelte, the following component compiles and functions as expected
However in the current Svelte 5 beta, an error is triggered saying
Expected a valid CSS identifier
. This is tested from a fresh install of SvelteKit runningnpm create svelte@latest
afterwards running
npm install svelte@next
to install Svelte 5
Not sure how support was implemented in Svelte 4 but it'd be great to have this working in the final release without having to download another package.
Reproduction URL
https://github.com/sortofsleepy/svelte5-vite-css-error
Reproduction
npm i svelte@latest
to compare and contrast.Logs
System Info
The text was updated successfully, but these errors were encountered: