Skip to content

Commit

Permalink
fix: let resolveBuiltUrl return a __VITE_ASSET__ reference
Browse files Browse the repository at this point in the history
  • Loading branch information
aleclarson committed Apr 19, 2021
1 parent a02eb2c commit f325977
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions packages/vite/src/node/plugins/asset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -284,9 +284,19 @@ async function resolveBuiltUrl(
) {
for (const { resolveBuiltUrl } of config.plugins) {
if (resolveBuiltUrl) {
const result = await resolveBuiltUrl.call(ctx, url)
if (result) {
return result
const builtUrl = await resolveBuiltUrl.call(ctx, url)
if (builtUrl) {
const match = builtUrl.match(/^__VITE_ASSET__(.+?)__/)
if (match) {
let map = assetHashToFilenameMap.get(config)
if (!map) {
map = new Map()
assetHashToFilenameMap.set(config, map)
}
const contentHash = match[1]
map.set(contentHash, ctx.getFileName(contentHash))
}
return builtUrl
}
}
}
Expand Down

0 comments on commit f325977

Please sign in to comment.