From f07e9b9d01d790c727edc2497304f07b1ef5d28f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BF=A0=20/=20green?= Date: Tue, 19 Nov 2024 14:08:14 +0900 Subject: [PATCH] chore: add some comments about mimes (#18705) --- packages/vite/src/node/constants.ts | 2 ++ packages/vite/src/node/plugins/asset.ts | 2 ++ 2 files changed, 4 insertions(+) diff --git a/packages/vite/src/node/constants.ts b/packages/vite/src/node/constants.ts index b251eddb6f03c9..596ffcdcdd0ebf 100644 --- a/packages/vite/src/node/constants.ts +++ b/packages/vite/src/node/constants.ts @@ -116,6 +116,8 @@ export const CLIENT_DIR = path.dirname(CLIENT_ENTRY) // add a mime type to the `registerCustomMime` in // `packages/vite/src/node/plugin/assets.ts` if mime type cannot be // looked up by mrmime. +// You can check if the mime type can be looked up by mrmime by running +// `node --print "require('mrmime').lookup('foo.png')"` export const KNOWN_ASSET_TYPES = [ // images 'apng', diff --git a/packages/vite/src/node/plugins/asset.ts b/packages/vite/src/node/plugins/asset.ts index 335ed6fbbb7701..fb9122b5b18b76 100644 --- a/packages/vite/src/node/plugins/asset.ts +++ b/packages/vite/src/node/plugins/asset.ts @@ -48,6 +48,8 @@ export const cssEntriesMap = new WeakMap>() // add own dictionary entry by directly assigning mrmime export function registerCustomMime(): void { // https://github.com/lukeed/mrmime/issues/3 + // instead of `image/vnd.microsoft.icon` which is registered on IANA Media Types DB + // image/x-icon should be used instead for better compatibility (https://github.com/h5bp/html5-boilerplate/issues/219) mrmime.mimes['ico'] = 'image/x-icon' // https://developer.mozilla.org/en-US/docs/Web/Media/Formats/Containers#flac mrmime.mimes['flac'] = 'audio/flac'