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

fix(legacy): emit css assets when cssCodeSplit and modernChuns is off #16125

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/plugin-legacy/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ function viteLegacyPlugin(options: Options = {}): Plugin[] {
// we'll delete the assets from the legacy bundle to avoid emitting duplicate assets.
// But that's still a waste of computing resource.
// So we add this flag to avoid emitting the asset in the first place whenever possible.
opts.__vite_skip_asset_emit__ = true
opts.__vite_skip_asset_emit__ = genModern

// avoid emitting assets for legacy bundle
const needPolyfills =
Expand Down
1 change: 1 addition & 0 deletions playground/legacy/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"build:multiple-output": "vite --config ./vite.config-multiple-output.js build",
"build:no-polyfills": "vite --config ./vite.config-no-polyfills.js build",
"build:no-polyfills-no-systemjs": "vite --config ./vite.config-no-polyfills-no-systemjs.js build",
"build:css-code-split": "vite --config ./vite.config-css-code-split.js build",
"build:watch": "vite --config ./vite.config-watch.js build --debug legacy",
"debug": "node --inspect-brk ../../packages/vite/bin/vite",
"preview": "vite preview"
Expand Down
21 changes: 21 additions & 0 deletions playground/legacy/vite.config-css-code-split.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import path from 'node:path'
import legacy from '@vitejs/plugin-legacy'
import { defineConfig } from 'vite'

export default defineConfig({
plugins: [
legacy({
renderModernChunks: false,
}),
],

build: {
outDir: 'dist/css-code-split',
cssCodeSplit: false,
rollupOptions: {
input: {
index: path.resolve(__dirname, 'index.html'),
},
},
},
})