Home / File/ serve.ts — vite Source File

serve.ts — vite Source File

Architecture documentation for serve.ts, a typescript file in the vite codebase. 4 imports, 0 dependents.

File typescript ViteCore ConfigEngine 4 imports 2 functions

Entity Profile

Dependency Diagram

graph LR
  69787096_db2c_92e4_449c_afb1439f9f27["serve.ts"]
  51e96894_3556_ed5c_1ede_97d449867adf["node:path"]
  69787096_db2c_92e4_449c_afb1439f9f27 --> 51e96894_3556_ed5c_1ede_97d449867adf
  946bdba3_227b_3fc0_1b4c_ddbdb281f454["node:http"]
  69787096_db2c_92e4_449c_afb1439f9f27 --> 946bdba3_227b_3fc0_1b4c_ddbdb281f454
  478585ae_10f6_2bf3_2a0e_79815903de88["sirv"]
  69787096_db2c_92e4_449c_afb1439f9f27 --> 478585ae_10f6_2bf3_2a0e_79815903de88
  d3fd5575_295b_d6be_24dd_62d277645dc9["~utils"]
  69787096_db2c_92e4_449c_afb1439f9f27 --> d3fd5575_295b_d6be_24dd_62d277645dc9
  style 69787096_db2c_92e4_449c_afb1439f9f27 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

// this is automatically detected by playground/vitestSetup.ts and will replace
// the default e2e test serve behavior

import path from 'node:path'
import http from 'node:http'
import sirv from 'sirv'
import {
  isBuild,
  page,
  ports,
  rootDir,
  serverLogs,
  setViteUrl,
  viteTestUrl,
} from '~utils'

const dirname = import.meta.dirname

export const port = ports.lib

export async function serve(): Promise<{ close(): Promise<void> }> {
  setupConsoleWarnCollector()

  if (!isBuild) {
    const { createServer } = await import('vite')
    process.env.VITE_INLINE = 'inline-serve'
    const viteServer = await (
      await createServer({
        root: rootDir,
        logLevel: 'silent',
        server: {
          port,
          strictPort: true,
          watch: {
            usePolling: true,
            interval: 100,
          },
          host: true,
          fs: {
            strict: !isBuild,
          },
        },
        build: {
          target: 'esnext',
        },
      })
    ).listen()
    // use resolved port/base from server
    const devBase = viteServer.config.base === '/' ? '' : viteServer.config.base
    setViteUrl(`http://localhost:${port}${devBase}`)
    await page.goto(viteTestUrl)

    return viteServer
  } else {
    const { build } = await import('vite')
    await build({
      root: rootDir,
      logLevel: 'silent',
      configFile: path.resolve(dirname, '../vite.config.js'),
    })
// ... (94 more lines)

Domain

Subdomains

Dependencies

  • node:http
  • node:path
  • sirv
  • ~utils

Frequently Asked Questions

What does serve.ts do?
serve.ts is a source file in the vite codebase, written in typescript. It belongs to the ViteCore domain, ConfigEngine subdomain.
What functions are defined in serve.ts?
serve.ts defines 2 function(s): serve, setupConsoleWarnCollector.
What does serve.ts depend on?
serve.ts imports 4 module(s): node:http, node:path, sirv, ~utils.
Where is serve.ts in the architecture?
serve.ts is located at playground/lib/__tests__/serve.ts (domain: ViteCore, subdomain: ConfigEngine, directory: playground/lib/__tests__).

Analyze Your Own Codebase

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

Try Supermodel Free