Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: legacy avoid insert the entry module css #9761

Merged
merged 2 commits into from Aug 19, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 8 additions & 0 deletions packages/vite/src/node/plugins/css.ts
Expand Up @@ -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
}
Comment on lines +560 to +567
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't quite caught up with the recent legacy changes, but are we now moving legacy-specific code into core? (just curious 😬)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This branch has always been in the css plugin. It would be great to move it plugin-legacy but there are some details where we are cheating from the inception of the plugin.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe no. The previous PR #9507 fix the legacy build css (this if branch) no replace the asset flag(__VITE_ASSET) because the css-post later than asset. This PR optimized legacy build css generate logic, and this if branch will trigger by legcy build. 😊

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