diff --git a/packages/vite/src/node/plugins/manifest.ts b/packages/vite/src/node/plugins/manifest.ts index a6e9608ed16c08..a82897ca6adb36 100644 --- a/packages/vite/src/node/plugins/manifest.ts +++ b/packages/vite/src/node/plugins/manifest.ts @@ -11,6 +11,8 @@ import { normalizePath, sortObjectKeys } from '../utils' import { generatedAssets } from './asset' import type { GeneratedAssetMeta } from './asset' +const endsWithJSRE = /\.[cm]?js$/ + export type Manifest = Record export interface ManifestChunk { @@ -134,7 +136,9 @@ export function manifestPlugin(config: ResolvedConfig): Plugin { // If JS chunk and asset chunk are both generated from the same source file, // prioritize JS chunk as it contains more information - if (manifest[src]?.file.endsWith('.js')) continue + const file = manifest[src]?.file + if (file && endsWithJSRE.test(file)) continue + manifest[src] = asset fileNameToAsset.set(chunk.fileName, asset) }