Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix: fileToBuiltUrl got undefined when file type is .ico (#7106)
  • Loading branch information
poyoho committed Feb 27, 2022
1 parent 79428ad commit 7a1a552
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/playground/assets/__tests__/assets.spec.ts
Expand Up @@ -121,6 +121,10 @@ describe('css url() references', () => {
const match = isBuild ? `data:image/png;base64` : `/foo/nested/icon.png`
expect(await getBg('.css-url-base64-inline')).toMatch(match)
expect(await getBg('.css-url-quotes-base64-inline')).toMatch(match)
const icoMatch = isBuild ? `data:image;base64` : `favicon.ico`
const el = await page.$(`link.ico`)
const herf = await el.getAttribute('href')
expect(herf).toMatch(icoMatch)
})

test('multiple urls on the same line', async () => {
Expand Down
Binary file added packages/playground/assets/favicon.ico
Binary file not shown.
1 change: 1 addition & 0 deletions packages/playground/assets/index.html
Expand Up @@ -2,6 +2,7 @@

<head>
<meta charset="UTF-8" />
<link class="ico" rel="icon" type="image/svg+xml" href="favicon.ico" />
</head>

<link rel="icon" href="data:," />
Expand Down
4 changes: 4 additions & 0 deletions packages/vite/src/node/plugins/asset.ts
Expand Up @@ -33,6 +33,10 @@ const emittedHashMap = new WeakMap<ResolvedConfig, Set<string>>()
export function assetPlugin(config: ResolvedConfig): Plugin {
// assetHashToFilenameMap initialization in buildStart causes getAssetFilename to return undefined
assetHashToFilenameMap.set(config, new Map())

// add own dictionary entry by directly assigning mrmine
// https://github.com/lukeed/mrmime/issues/3
mrmime.mimes['ico'] = 'image'
return {
name: 'vite:asset',

Expand Down

0 comments on commit 7a1a552

Please sign in to comment.