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

feat(plugin-legacy): add option to output only legacy builds #10139

Merged
merged 8 commits into from
Jul 4, 2023
Prev Previous commit
Next Next commit
fix: inline entry css if modern bundle is skipped
  • Loading branch information
lsdsjy committed Nov 21, 2022
commit 2e63b8aeb630d26743844eb350530b0dcaf5ccac
11 changes: 11 additions & 0 deletions packages/plugin-legacy/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,17 @@ function viteLegacyPlugin(options: Options = {}): Plugin[] {
}
},

renderStart(opts) {
// @ts-ignore
// In the `renderChunk` hook,
// we skip inlining CSS for the entry chunk because a separate CSS file
// would've been already linked in index.html (see #9761).
// But if `genModern` is set to false, the CSS still should be inlined.
// If in the future vite doesn't inline CSS any more (as #9920 suggests),
// this flag can be safely deleted.
opts.__vite_inline_entry_css__ = !genModern
},

async renderChunk(raw, chunk, opts) {
if (config.build.ssr) {
return null
Expand Down