diff --git a/packages/vite/src/node/plugins/importAnalysis.ts b/packages/vite/src/node/plugins/importAnalysis.ts index a7a77968e..8281c1bcb 100644 --- a/packages/vite/src/node/plugins/importAnalysis.ts +++ b/packages/vite/src/node/plugins/importAnalysis.ts @@ -509,7 +509,10 @@ export function importAnalysisPlugin(config: ResolvedConfig): Plugin { // If resolvable, let's resolve it if (specifier !== undefined) { // skip external / data uri - if (isExternalUrl(specifier) || isDataUrl(specifier)) { + if ( + (isExternalUrl(specifier) && !specifier.startsWith('file://')) || + isDataUrl(specifier) + ) { return } // skip ssr externals and builtins diff --git a/packages/vite/src/node/utils.ts b/packages/vite/src/node/utils.ts index fa50fc882..8b234f20c 100644 --- a/packages/vite/src/node/utils.ts +++ b/packages/vite/src/node/utils.ts @@ -262,7 +262,7 @@ export function isSameFileUri(file1: string, file2: string): boolean { ) } -export const externalRE = /^(https?:)?\/\// +export const externalRE = /^([a-z]+:)?\/\// export const isExternalUrl = (url: string): boolean => externalRE.test(url) export const dataUrlRE = /^\s*data:/i