From a865db909fa1f3f8d7d2f2b83afdba23b5cbd4f0 Mon Sep 17 00:00:00 2001 From: Marine Dunstetter Date: Tue, 19 Mar 2024 17:45:59 +0100 Subject: [PATCH] make sure / and ./ can match when comparing assets URL, "normalize" the dest path of the emitted file --- packages/vite/src/assets.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/vite/src/assets.ts b/packages/vite/src/assets.ts index 4f4957ad4c..d180d4fcde 100644 --- a/packages/vite/src/assets.ts +++ b/packages/vite/src/assets.ts @@ -15,7 +15,9 @@ function findPublicAsset(relativePath: string, resolver: Resolver) { for (const addon of engine.activeAddons) { pkg = packageCache.ownerOfFile(addon.root); if (pkg && pkg.meta && pkg.isV2Addon() && pkg.meta['public-assets']) { - const asset = Object.entries(pkg.meta['public-assets']).find(([_key, a]) => a === relativePath)?.[0]; + const asset = Object.entries(pkg.meta['public-assets']).find( + ([_key, a]) => join('.', a) === join('.', relativePath) + )?.[0]; let local = asset ? join(addon.root, asset) : null; if (local && existsSync(local)) { return local; @@ -66,7 +68,7 @@ export function assets(): Plugin { this.emitFile({ type: 'asset', source: readFileSync(join(pkg.root, path)), - fileName: dest.slice(1), + fileName: join('.', dest), }); }); });