Skip to content

Commit 06d7c1a

Browse files
fix(svelte-scoped): generate in buildEnd() to make presetWind4 on-dem… (#5133)
1 parent 4331330 commit 06d7c1a

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,21 @@ export function GlobalStylesPlugin(ctx: SvelteScopedContext, injectReset?: Unocs
5353
// build
5454
async buildStart() {
5555
if (viteConfig.command === 'build') {
56-
const css = await generateGlobalCss(ctx.uno, injectReset)
5756
unoCssFileReferenceId = this.emitFile({
5857
type: 'asset',
5958
name: GLOBAL_STYLES_CSS_FILE_NAME,
60-
source: css,
6159
})
6260
}
6361
},
6462

63+
// build - runs after all module transforms complete, so on-demand theme tokens are fully tracked
64+
async buildEnd() {
65+
if (viteConfig.command === 'build') {
66+
const css = await generateGlobalCss(ctx.uno, injectReset)
67+
this.setAssetSource(unoCssFileReferenceId, css)
68+
}
69+
},
70+
6571
// build
6672
renderStart() {
6773
unoCssGlobalFileName = this.getFileName(unoCssFileReferenceId)

0 commit comments

Comments
 (0)