Skip to content

Commit

Permalink
chore: format
Browse files Browse the repository at this point in the history
  • Loading branch information
patak-dev committed Jun 27, 2022
1 parent 99b578b commit 5588a6d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
17 changes: 11 additions & 6 deletions packages/plugin-legacy/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,16 @@ function toOutputFilePathInHtml(
const { renderBuiltUrl } = config.experimental
let relative = config.base === '' || config.base === './'
if (renderBuiltUrl) {
const result = renderBuiltUrl(filename, {
hostId,
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}`
`{ runtime: "${result.runtime}" } is not supported for assets in ${hostType} files: ${filename}`
)
}
if (typeof result.relative === 'boolean') {
Expand Down Expand Up @@ -90,7 +88,14 @@ function toAssetPathFromHtml(
const relativeUrlPath = normalizePath(path.relative(config.root, htmlPath))
const toRelative = (filename: string, hostId: string) =>
getBaseInHTML(relativeUrlPath, config) + filename
return toOutputFilePathInHtml(filename, 'asset', htmlPath, 'html', config, toRelative)
return toOutputFilePathInHtml(
filename,
'asset',
htmlPath,
'html',
config,
toRelative
)
}

// https://gist.github.com/samthor/64b114e4a4f539915a95b91ffd340acc
Expand Down
10 changes: 4 additions & 6 deletions packages/vite/src/node/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -833,11 +833,11 @@ function injectSsrFlag<T extends Record<string, any>>(

export type RenderBuiltAssetUrl = (
filename: string,
type: {
type: {
type: 'asset' | 'public'
hostId: string,
hostId: string
hostType: 'js' | 'css' | 'html'
ssr: boolean
ssr: boolean
}
) => string | { relative?: boolean; runtime?: string } | undefined

Expand Down Expand Up @@ -898,9 +898,7 @@ export function toOutputFilePathWithoutRuntime(
if (typeof result === 'object') {
if (result.runtime) {
throw new Error(
`{ runtime: "${
result.runtime
} }" is not supported for assets in ${hostType} files: ${filename}`
`{ runtime: "${result.runtime} }" is not supported for assets in ${hostType} files: ${filename}`
)
}
if (typeof result.relative === 'boolean') {
Expand Down

0 comments on commit 5588a6d

Please sign in to comment.