Home / Function/ updateStyle() — vite Function Reference

updateStyle() — vite Function Reference

Architecture documentation for the updateStyle() function in client.ts from the vite codebase.

Entity Profile

Dependency Diagram

graph TD
  a6a692ad_7c08_7158_1054_ead2117abc18["updateStyle()"]
  85908ff5_4d12_826d_8235_531f91538758["client.ts"]
  a6a692ad_7c08_7158_1054_ead2117abc18 -->|defined in| 85908ff5_4d12_826d_8235_531f91538758
  style a6a692ad_7c08_7158_1054_ead2117abc18 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/vite/src/client/client.ts lines 548–577

export function updateStyle(id: string, content: string): void {
  if (linkSheetsMap.has(id)) return

  let style = sheetsMap.get(id)
  if (!style) {
    style = document.createElement('style')
    style.setAttribute('type', 'text/css')
    style.setAttribute('data-vite-dev-id', id)
    style.textContent = content
    if (cspNonce) {
      style.setAttribute('nonce', cspNonce)
    }

    if (!lastInsertedStyle) {
      document.head.appendChild(style)

      // reset lastInsertedStyle after async
      // because dynamically imported css will be split into a different file
      setTimeout(() => {
        lastInsertedStyle = undefined
      }, 0)
    } else {
      lastInsertedStyle.insertAdjacentElement('afterend', style)
    }
    lastInsertedStyle = style
  } else {
    style.textContent = content
  }
  sheetsMap.set(id, style)
}

Domain

Subdomains

Frequently Asked Questions

What does updateStyle() do?
updateStyle() is a function in the vite codebase, defined in packages/vite/src/client/client.ts.
Where is updateStyle() defined?
updateStyle() is defined in packages/vite/src/client/client.ts at line 548.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free