Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: undefined document in worker #12988

Merged
merged 2 commits into from Apr 26, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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