( filename: string, type: 'asset' | 'public', hostId: string, hostType: 'js' | 'css' | 'html', config: ResolvedConfig, toRelative: (filename: string, hostId: string) => string, )
| 1678 | } |
| 1679 | |
| 1680 | export function toOutputFilePathWithoutRuntime( |
| 1681 | filename: string, |
| 1682 | type: 'asset' | 'public', |
| 1683 | hostId: string, |
| 1684 | hostType: 'js' | 'css' | 'html', |
| 1685 | config: ResolvedConfig, |
| 1686 | toRelative: (filename: string, hostId: string) => string, |
| 1687 | ): string { |
| 1688 | const { renderBuiltUrl } = config.experimental |
| 1689 | let relative = config.base === '' || config.base === './' |
| 1690 | if (renderBuiltUrl) { |
| 1691 | const result = renderBuiltUrl(filename, { |
| 1692 | hostId, |
| 1693 | hostType, |
| 1694 | type, |
| 1695 | ssr: !!config.build.ssr, |
| 1696 | }) |
| 1697 | if (typeof result === 'object') { |
| 1698 | if (result.runtime) { |
| 1699 | throw new Error( |
| 1700 | `{ runtime: "${result.runtime}" } is not supported for assets in ${hostType} files: ${filename}`, |
| 1701 | ) |
| 1702 | } |
| 1703 | if (typeof result.relative === 'boolean') { |
| 1704 | relative = result.relative |
| 1705 | } |
| 1706 | } else if (result) { |
| 1707 | return result |
| 1708 | } |
| 1709 | } |
| 1710 | if (relative && !config.build.ssr) { |
| 1711 | return toRelative(filename, hostId) |
| 1712 | } else { |
| 1713 | return joinUrlSegments(config.decodedBase, filename) |
| 1714 | } |
| 1715 | } |
| 1716 | |
| 1717 | export const toOutputFilePathInCss: typeof toOutputFilePathWithoutRuntime = |
| 1718 | toOutputFilePathWithoutRuntime |
nothing calls this directly
no test coverage detected