fix(legacy): emit css assets when no cssCodeSplit and modernChuns are off

This commit is contained in:
armano 2024-03-08 21:48:11 +01:00
parent fd9de0473e
commit db125a7067
3 changed files with 23 additions and 1 deletions

View File

@ -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 =

View File

@ -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"

View File

@ -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'),
},
},
},
})