Skip to content

Commit

Permalink
fix(legacy): restore entry chunk CSS inlining, reverts #9761 (#10496)
Browse files Browse the repository at this point in the history
  • Loading branch information
sapphi-red committed Oct 17, 2022
1 parent 2326f4a commit 9cc808e
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions packages/vite/src/node/plugins/css.ts
Expand Up @@ -566,12 +566,12 @@ export function cssPostPlugin(config: ResolvedConfig): Plugin {
} 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 && !config.build.lib) {
return null
}
// Entry chunk CSS will be collected into `chunk.viteMetadata.importedCss`
// and injected later by the `'vite:build-html'` plugin into the `index.html`
// so it will be duplicated. (https://github.com/vitejs/vite/issues/2062#issuecomment-782388010)
// But because entry chunk can be imported by dynamic import,
// we shouldn't remove the inlined CSS. (#10285)

chunkCSS = await finalizeCss(chunkCSS, true, config)
let cssString = JSON.stringify(chunkCSS)
cssString =
Expand Down

0 comments on commit 9cc808e

Please sign in to comment.