File tree Expand file tree Collapse file tree 3 files changed +17
-12
lines changed
packages/react-router-dev/vite Expand file tree Collapse file tree 3 files changed +17
-12
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ " @react-router/dev " : major
3+ ---
4+
5+ Load vite env variables before reading routes.ts
Original file line number Diff line number Diff line change @@ -1279,20 +1279,20 @@ export const reactRouterVitePlugin: ReactRouterVitePlugin = () => {
12791279 } ) ;
12801280 }
12811281
1282- reactRouterConfigLoader = await createConfigLoader ( {
1282+ await loadDotenv ( {
12831283 rootDirectory,
1284+ viteUserConfig,
12841285 mode,
1285- watch : viteCommand === "serve" ,
12861286 } ) ;
12871287
1288- await updatePluginContext ( ) ;
1289-
1290- await loadDotenv ( {
1288+ reactRouterConfigLoader = await createConfigLoader ( {
12911289 rootDirectory,
1292- viteUserConfig,
12931290 mode,
1291+ watch : viteCommand === "serve" ,
12941292 } ) ;
12951293
1294+ await updatePluginContext ( ) ;
1295+
12961296 let environments = await getEnvironmentsOptions ( ctx , viteCommand , {
12971297 viteUserConfig,
12981298 } ) ;
Original file line number Diff line number Diff line change @@ -60,6 +60,12 @@ export function reactRouterRSCVitePlugin(): Vite.PluginOption[] {
6060 const rootDirectory = getRootDirectory ( viteUserConfig ) ;
6161 const watch = command === "serve" ;
6262
63+ await loadDotenv ( {
64+ rootDirectory,
65+ viteUserConfig,
66+ mode,
67+ } ) ;
68+
6369 configLoader = await createConfigLoader ( {
6470 rootDirectory,
6571 mode,
@@ -104,12 +110,6 @@ export function reactRouterRSCVitePlugin(): Vite.PluginOption[] {
104110 ) ;
105111 }
106112
107- await loadDotenv ( {
108- rootDirectory,
109- viteUserConfig,
110- mode,
111- } ) ;
112-
113113 const vite = await import ( "vite" ) ;
114114 logger = vite . createLogger ( viteUserConfig . logLevel , {
115115 prefix : "[react-router]" ,
You can’t perform that action at this time.
0 commit comments