Skip to content

Commit 1cd0335

Browse files
committed
fix(vite): loadEnv before reading routes
1 parent 531eeed commit 1cd0335

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
@@ -1205,20 +1205,20 @@ export const reactRouterVitePlugin: ReactRouterVitePlugin = () => {
12051205
});
12061206
}
12071207

1208-
reactRouterConfigLoader = await createConfigLoader({
1208+
await loadDotenv({
12091209
rootDirectory,
1210+
viteUserConfig,
12101211
mode,
1211-
watch: viteCommand === "serve",
12121212
});
12131213

1214-
await updatePluginContext();
1215-
1216-
await loadDotenv({
1214+
reactRouterConfigLoader = await createConfigLoader({
12171215
rootDirectory,
1218-
viteUserConfig,
12191216
mode,
1217+
watch: viteCommand === "serve",
12201218
});
12211219

1220+
await updatePluginContext();
1221+
12221222
let environments = await getEnvironmentsOptions(ctx, viteCommand, {
12231223
viteUserConfig,
12241224
});

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)