From 0765ab812f410d5b925a742419ea2b1586b0da23 Mon Sep 17 00:00:00 2001 From: yoho Date: Fri, 19 Aug 2022 23:38:05 +0800 Subject: [PATCH] perf: legacy avoid insert the entry module css (#9761) --- packages/vite/src/node/plugins/css.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/packages/vite/src/node/plugins/css.ts b/packages/vite/src/node/plugins/css.ts index c8c454d2f1a267..4dc3aa7f158587 100644 --- a/packages/vite/src/node/plugins/css.ts +++ b/packages/vite/src/node/plugins/css.ts @@ -557,6 +557,14 @@ export function cssPostPlugin(config: ResolvedConfig): Plugin { }) chunk.viteMetadata.importedCss.add(this.getFileName(fileHandle)) } else if (!config.build.ssr) { + // legacy build and inline css + + // the legacy build should avoid inserting entry CSS modules here, they + // will be collected into `chunk.viteMetadata.importedCss` and injected + // later by the `'vite:build-html'` plugin into the `index.html` + if (chunk.isEntry) { + return null + } chunkCSS = await finalizeCss(chunkCSS, true, config) let cssString = JSON.stringify(chunkCSS) cssString =