(
filename: string,
type: 'asset' | 'public',
hostId: string,
hostType: 'js' | 'css' | 'html',
config: ResolvedConfig,
toRelative: (filename: string, hostType: string) => string | { runtime: string }
)
| 81 | * @internal |
| 82 | */ |
| 83 | export function toOutputFilePathInJS( |
| 84 | filename: string, |
| 85 | type: 'asset' | 'public', |
| 86 | hostId: string, |
| 87 | hostType: 'js' | 'css' | 'html', |
| 88 | config: ResolvedConfig, |
| 89 | toRelative: (filename: string, hostType: string) => string | { runtime: string } |
| 90 | ): string | { runtime: string } { |
| 91 | const { renderBuiltUrl } = config.experimental; |
| 92 | let relative = config.base === '' || config.base === './'; |
| 93 | if (renderBuiltUrl) { |
| 94 | const result = renderBuiltUrl(filename, { |
| 95 | hostId, |
| 96 | hostType, |
| 97 | type, |
| 98 | ssr: !!config.build.ssr |
| 99 | }); |
| 100 | if (typeof result === 'object') { |
| 101 | if (result.runtime) { |
| 102 | return { runtime: result.runtime }; |
| 103 | } |
| 104 | if (typeof result.relative === 'boolean') { |
| 105 | relative = result.relative; |
| 106 | } |
| 107 | } else if (result) { |
| 108 | return result; |
| 109 | } |
| 110 | } |
| 111 | if (relative && !config.build.ssr) { |
| 112 | return toRelative(filename, hostId); |
| 113 | } |
| 114 | return joinUrlSegments(config.base, filename); |
| 115 | } |
| 116 | |
| 117 | // https://github.com/vitejs/vite/blob/v6.1.1/packages/vite/src/node/build.ts#L1131 |
| 118 |
no test coverage detected