diff --git a/packages/vite/src/node/plugins/asset.ts b/packages/vite/src/node/plugins/asset.ts index e62ead24a0e20c..22bf21a8f1a80d 100644 --- a/packages/vite/src/node/plugins/asset.ts +++ b/packages/vite/src/node/plugins/asset.ts @@ -204,6 +204,7 @@ export function assetPlugin(config: ResolvedConfig): Plugin { config.command === 'build' && this.getModuleInfo(id)?.isEntry ? 'no-treeshake' : false, + meta: config.command === 'build' ? { 'vite:asset': true } : undefined, } }, @@ -230,7 +231,8 @@ export function assetPlugin(config: ResolvedConfig): Plugin { chunk.type === 'chunk' && chunk.isEntry && chunk.moduleIds.length === 1 && - config.assetsInclude(chunk.moduleIds[0]) + config.assetsInclude(chunk.moduleIds[0]) && + this.getModuleInfo(chunk.moduleIds[0])?.meta['vite:asset'] ) { delete bundle[file] }