Home / Function/ toOutputFilePathInJS() — vite Function Reference

toOutputFilePathInJS() — vite Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  0b9e0d55_d22c_da82_ca1d_a2e7d0af1d66["toOutputFilePathInJS()"]
  45981d85_cbdd_e969_8c88_c17072ea0eda["build.ts"]
  0b9e0d55_d22c_da82_ca1d_a2e7d0af1d66 -->|defined in| 45981d85_cbdd_e969_8c88_c17072ea0eda
  edf78a01_8215_eb46_3896_3db717c46747["renderAssetUrlInJS()"]
  edf78a01_8215_eb46_3896_3db717c46747 -->|calls| 0b9e0d55_d22c_da82_ca1d_a2e7d0af1d66
  b8f7857f_eb38_9730_a8eb_658b77a590c9["toOutputFilePathInJSForBundledDev()"]
  b8f7857f_eb38_9730_a8eb_658b77a590c9 -->|calls| 0b9e0d55_d22c_da82_ca1d_a2e7d0af1d66
  cd131d16_e223_ab79_1b7c_8ea449ae51a2["cssPostPlugin()"]
  cd131d16_e223_ab79_1b7c_8ea449ae51a2 -->|calls| 0b9e0d55_d22c_da82_ca1d_a2e7d0af1d66
  6d315957_5b5c_845c_10c4_b8cb46bc58eb["buildImportAnalysisPlugin()"]
  6d315957_5b5c_845c_10c4_b8cb46bc58eb -->|calls| 0b9e0d55_d22c_da82_ca1d_a2e7d0af1d66
  1a156a4f_5015_f60f_3a54_6eb2168861ca["webWorkerPlugin()"]
  1a156a4f_5015_f60f_3a54_6eb2168861ca -->|calls| 0b9e0d55_d22c_da82_ca1d_a2e7d0af1d66
  c9db8630_93b3_267d_8e26_8b62626a11ca["joinUrlSegments()"]
  0b9e0d55_d22c_da82_ca1d_a2e7d0af1d66 -->|calls| c9db8630_93b3_267d_8e26_8b62626a11ca
  style 0b9e0d55_d22c_da82_ca1d_a2e7d0af1d66 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/vite/src/node/build.ts lines 1591–1628

export function toOutputFilePathInJS(
  environment: PartialEnvironment,
  filename: string,
  type: 'asset' | 'public',
  hostId: string,
  hostType: 'js' | 'css' | 'html',
  toRelative: (
    filename: string,
    hostType: string,
  ) => string | { runtime: string },
): string | { runtime: string } {
  const { experimental, base, decodedBase } = environment.config
  const ssr = environment.config.consumer === 'server' // was !!environment.config.build.ssr
  const { renderBuiltUrl } = experimental
  let relative = base === '' || base === './'
  if (renderBuiltUrl) {
    const result = renderBuiltUrl(filename, {
      hostId,
      hostType,
      type,
      ssr,
    })
    if (typeof result === 'object') {
      if (result.runtime) {
        return { runtime: result.runtime }
      }
      if (typeof result.relative === 'boolean') {
        relative = result.relative
      }
    } else if (result) {
      return result
    }
  }
  if (relative && !ssr) {
    return toRelative(filename, hostId)
  }
  return joinUrlSegments(decodedBase, filename)
}

Domain

Subdomains

Frequently Asked Questions

What does toOutputFilePathInJS() do?
toOutputFilePathInJS() is a function in the vite codebase, defined in packages/vite/src/node/build.ts.
Where is toOutputFilePathInJS() defined?
toOutputFilePathInJS() is defined in packages/vite/src/node/build.ts at line 1591.
What does toOutputFilePathInJS() call?
toOutputFilePathInJS() calls 1 function(s): joinUrlSegments.
What calls toOutputFilePathInJS()?
toOutputFilePathInJS() is called by 5 function(s): buildImportAnalysisPlugin, cssPostPlugin, renderAssetUrlInJS, toOutputFilePathInJSForBundledDev, webWorkerPlugin.

Analyze Your Own Codebase

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

Try Supermodel Free