Home / Function/ serve() — vite Function Reference

serve() — vite Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  a6b0fcd1_e862_160f_4370_2a0fcc92219c["serve()"]
  a657842b_85c2_e980_4bc8_cf15be13a5fb["serve.ts"]
  a6b0fcd1_e862_160f_4370_2a0fcc92219c -->|defined in| a657842b_85c2_e980_4bc8_cf15be13a5fb
  style a6b0fcd1_e862_160f_4370_2a0fcc92219c fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

playground/proxy-hmr/__tests__/serve.ts lines 7–27

export async function serve(): Promise<{ close(): Promise<void> }> {
  const vite = await import('vite')
  const rootServer = await vite.createServer({
    root: rootDir,
    logLevel: 'silent',
  })
  const otherServer = await vite.createServer({
    root: path.join(rootDir, 'other-app'),
    logLevel: 'silent',
  })

  await Promise.all([rootServer.listen(), otherServer.listen()])
  const viteUrl = rootServer.resolvedUrls.local[0]
  setViteUrl(viteUrl)

  return {
    async close() {
      await Promise.all([rootServer.close(), otherServer.close()])
    },
  }
}

Domain

Subdomains

Frequently Asked Questions

What does serve() do?
serve() is a function in the vite codebase, defined in playground/proxy-hmr/__tests__/serve.ts.
Where is serve() defined?
serve() is defined in playground/proxy-hmr/__tests__/serve.ts at line 7.

Analyze Your Own Codebase

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

Try Supermodel Free