Skip to content

Commit 0599a93

Browse files
committed
fix(vite): loadEnv before reading routes
1 parent 447a784 commit 0599a93

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

packages/react-router-dev/vite/plugin.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1207,20 +1207,20 @@ export const reactRouterVitePlugin: ReactRouterVitePlugin = () => {
12071207
});
12081208
}
12091209

1210-
reactRouterConfigLoader = await createConfigLoader({
1210+
await loadDotenv({
12111211
rootDirectory,
1212+
viteUserConfig,
12121213
mode,
1213-
watch: viteCommand === "serve",
12141214
});
12151215

1216-
await updatePluginContext();
1217-
1218-
await loadDotenv({
1216+
reactRouterConfigLoader = await createConfigLoader({
12191217
rootDirectory,
1220-
viteUserConfig,
12211218
mode,
1219+
watch: viteCommand === "serve",
12221220
});
12231221

1222+
await updatePluginContext();
1223+
12241224
let environments = await getEnvironmentsOptions(ctx, viteCommand, {
12251225
viteUserConfig,
12261226
});

packages/react-router-dev/vite/rsc/plugin.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff 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]",

0 commit comments

Comments
 (0)