Skip to content

Commit

Permalink
fix: undefined document in worker (#12988)
Browse files Browse the repository at this point in the history
  • Loading branch information
patak-dev committed Apr 26, 2023
1 parent bd86375 commit 08c1452
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions packages/vite/src/client/client.ts
Expand Up @@ -365,9 +365,11 @@ const sheetsMap = new Map<string, HTMLStyleElement>()

// collect existing style elements that may have been inserted during SSR
// to avoid FOUC or duplicate styles
document.querySelectorAll('style[data-vite-dev-id]').forEach((el) => {
sheetsMap.set(el.getAttribute('data-vite-dev-id')!, el as HTMLStyleElement)
})
if ('document' in globalThis) {
document.querySelectorAll('style[data-vite-dev-id]').forEach((el) => {
sheetsMap.set(el.getAttribute('data-vite-dev-id')!, el as HTMLStyleElement)
})
}

// all css imports should be inserted at the same position
// because after build it will be a single css file
Expand Down

0 comments on commit 08c1452

Please sign in to comment.