Skip to content

Commit

Permalink
fix(build): ignore html asset urls that do not exist on disk
Browse files Browse the repository at this point in the history
fix #1885
  • Loading branch information
yyx990803 committed Feb 5, 2021
1 parent d6bf066 commit 02653f0
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions packages/vite/src/node/plugins/html.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,17 @@ export function buildHtmlPlugin(config: ResolvedConfig): Plugin {
// references the post-build location.
for (const attr of assetUrls) {
const value = attr.value!
const url = await urlToBuiltUrl(value.content, id, config, this)
s.overwrite(value.loc.start.offset, value.loc.end.offset, `"${url}"`)
try {
const url = await urlToBuiltUrl(value.content, id, config, this)
s.overwrite(
value.loc.start.offset,
value.loc.end.offset,
`"${url}"`
)
} catch (e) {
// #1885 preload may be pointing to urls that do not exist
// locally on disk
}
}

processedHtml.set(id, s.toString())
Expand Down

0 comments on commit 02653f0

Please sign in to comment.