Home / Function/ toOutputFilePathInHtml() — vite Function Reference

toOutputFilePathInHtml() — vite Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  93378aa0_5b0f_e84a_a1cf_4da651efbca1["toOutputFilePathInHtml()"]
  9776ecb6_00c0_b3b9_b3f7_177fedabeacc["index.ts"]
  93378aa0_5b0f_e84a_a1cf_4da651efbca1 -->|defined in| 9776ecb6_00c0_b3b9_b3f7_177fedabeacc
  e4d2379b_4e77_cb47_c192_09b680b7570b["toAssetPathFromHtml()"]
  e4d2379b_4e77_cb47_c192_09b680b7570b -->|calls| 93378aa0_5b0f_e84a_a1cf_4da651efbca1
  f7066b1b_88f3_440e_8604_7291c3676851["joinUrlSegments()"]
  93378aa0_5b0f_e84a_a1cf_4da651efbca1 -->|calls| f7066b1b_88f3_440e_8604_7291c3676851
  style 93378aa0_5b0f_e84a_a1cf_4da651efbca1 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/plugin-legacy/src/index.ts lines 43–78

function toOutputFilePathInHtml(
  filename: string,
  type: 'asset' | 'public',
  hostId: string,
  hostType: 'js' | 'css' | 'html',
  config: ResolvedConfig,
  toRelative: (filename: string, importer: string) => string,
): string {
  const { renderBuiltUrl } = config.experimental
  let relative = config.base === '' || config.base === './'
  if (renderBuiltUrl) {
    const result = renderBuiltUrl(filename, {
      hostId,
      hostType,
      type,
      ssr: !!config.build.ssr,
    })
    if (typeof result === 'object') {
      if (result.runtime) {
        throw new Error(
          `{ runtime: "${result.runtime}" } is not supported for assets in ${hostType} files: ${filename}`,
        )
      }
      if (typeof result.relative === 'boolean') {
        relative = result.relative
      }
    } else if (result) {
      return result
    }
  }
  if (relative && !config.build.ssr) {
    return toRelative(filename, hostId)
  } else {
    return joinUrlSegments(config.decodedBase, filename)
  }
}

Domain

Subdomains

Frequently Asked Questions

What does toOutputFilePathInHtml() do?
toOutputFilePathInHtml() is a function in the vite codebase, defined in packages/plugin-legacy/src/index.ts.
Where is toOutputFilePathInHtml() defined?
toOutputFilePathInHtml() is defined in packages/plugin-legacy/src/index.ts at line 43.
What does toOutputFilePathInHtml() call?
toOutputFilePathInHtml() calls 1 function(s): joinUrlSegments.
What calls toOutputFilePathInHtml()?
toOutputFilePathInHtml() is called by 1 function(s): toAssetPathFromHtml.

Analyze Your Own Codebase

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

Try Supermodel Free