Skip to content

Commit

Permalink
make sure / and ./ can match when comparing assets URL, "normalize" t…
Browse files Browse the repository at this point in the history
…he dest path of the emitted file
  • Loading branch information
BlueCutOfficial committed Mar 20, 2024
1 parent 659abf2 commit a865db9
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/vite/src/assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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),
});
});
});
Expand Down

0 comments on commit a865db9

Please sign in to comment.