From 6a8a9fb238c18809d6cdda65ebf86f712eedf984 Mon Sep 17 00:00:00 2001 From: mia-cx Date: Wed, 22 Mar 2023 02:35:04 +0100 Subject: [PATCH] add opus to assets & mime types --- packages/vite/client.d.ts | 5 +++++ packages/vite/src/node/constants.ts | 1 + packages/vite/src/node/plugins/asset.ts | 2 ++ 3 files changed, 8 insertions(+) diff --git a/packages/vite/client.d.ts b/packages/vite/client.d.ts index a7182c8fd454d9..b55e4eba33d41c 100644 --- a/packages/vite/client.d.ts +++ b/packages/vite/client.d.ts @@ -173,6 +173,11 @@ declare module '*.aac' { export default src } +declare module '*.opus' { + const src: string + export default src +} + // fonts declare module '*.woff' { const src: string diff --git a/packages/vite/src/node/constants.ts b/packages/vite/src/node/constants.ts index f2d3c161d8d84c..0f378bbdfb9f9f 100644 --- a/packages/vite/src/node/constants.ts +++ b/packages/vite/src/node/constants.ts @@ -115,6 +115,7 @@ export const KNOWN_ASSET_TYPES = [ 'wav', 'flac', 'aac', + 'opus', // fonts 'woff2?', diff --git a/packages/vite/src/node/plugins/asset.ts b/packages/vite/src/node/plugins/asset.ts index 134625c87dd078..21f8a4d5109be7 100644 --- a/packages/vite/src/node/plugins/asset.ts +++ b/packages/vite/src/node/plugins/asset.ts @@ -47,6 +47,8 @@ export function registerCustomMime(): void { mrmime.mimes['flac'] = 'audio/flac' // mrmime and mime-db is not released yet: https://github.com/jshttp/mime-db/commit/c9242a9b7d4bb25d7a0c9244adec74aeef08d8a1 mrmime.mimes['aac'] = 'audio/aac' + // https://wiki.xiph.org/MIME_Types_and_File_Extensions#.opus_-_audio/ogg + mrmime.mimes['opus'] = 'audio/ogg' // https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types mrmime.mimes['eot'] = 'application/vnd.ms-fontobject' }