Skip to content

Commit bc77edd

Browse files
fix(svelte-scoped): use SvelteKit assets path for the global stylesheet link (#5267)
Co-authored-by: Henrik Berglund <110549389+henrikvilhelmberglund@users.noreply.github.com>
1 parent d81b28b commit bc77edd

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

packages-integrations/svelte-scoped/src/_vite/globalStylesPlugin.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ export function GlobalStylesPlugin(ctx: UnocssPluginContext, injectReset?: Unocs
7070
// build
7171
renderChunk(code) {
7272
if (isSvelteKit && code.includes(PLACEHOLDER_USER_SETS_IN_INDEX_HTML)) {
73-
// This replaces inside a file generated from the `app.html`. The placeholder is wrapped inside double quotes, thus the escaping.
74-
const tag = `<link href=\\"${viteConfig.base ?? '/'}${unoCssGlobalFileName}\\" rel=\\"stylesheet\\" />`
73+
// This replaces inside a file generated from the `app.html`. The placeholder is wrapped inside double quotes, thus the escaping. The href is concatenated with SvelteKit's `assets` template variable, as the vite base of the server build does not carry `kit.paths`.
74+
const tag = `<link href=\\"" + assets + "/${unoCssGlobalFileName}\\" rel=\\"stylesheet\\" />`
7575

7676
return code.replace(PLACEHOLDER_USER_SETS_IN_INDEX_HTML, tag)
7777
}

0 commit comments

Comments
 (0)
Sponsor
SponsoredKunjungi sekarang
Promo