File tree Expand file tree Collapse file tree 2 files changed +11
-0
lines changed
Expand file tree Collapse file tree 2 files changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,8 @@ const mode = import.meta.env.MODE
55const site_id = import . meta. env . VITE_SITE_ID
66
77// Use Vite's import.meta.glob to conditionally load mode-specific configs
8+ // This will actually only include the specific config file of the current mode
9+ // thanks to vite.config.mts dynamicImport plugin
810const modeConfigs = import . meta. glob ( '@siteConfig/config.*.yaml' , {
911 eager : true
1012} )
Original file line number Diff line number Diff line change @@ -90,6 +90,15 @@ export default defineConfig(({ mode }) => {
9090 routeFile . includes ( `custom/${ env . VITE_SITE_ID } /routes.ts` )
9191 )
9292 }
93+ // Include only the current mode's config file in the bundle
94+ // to prevent /src/config.ts from including all config files before picking the right one
95+ if ( id . includes ( '/src/config.ts' ) ) {
96+ return files . filter ( ( configFile ) =>
97+ configFile . includes (
98+ `configs/${ env . VITE_SITE_ID } /config.${ mode } .yaml`
99+ )
100+ )
101+ }
93102 }
94103 } )
95104 ] ,
You can’t perform that action at this time.
0 commit comments