Skip to content

Commit fa00680

Browse files
Remove redundant Vite preview SPA build config (#12920)
1 parent 2251663 commit fa00680

File tree

3 files changed

+13
-40
lines changed

3 files changed

+13
-40
lines changed

Diff for: packages/react-router-dev/vite/plugin.ts

+9-40
Original file line numberDiff line numberDiff line change
@@ -1017,12 +1017,15 @@ export const reactRouterVitePlugin: ReactRouterVitePlugin = () => {
10171017
? { fs: { allow: defaultEntries } }
10181018
: undefined,
10191019

1020-
build: await resolveBuildOptions({
1021-
ctx,
1022-
viteCommand,
1023-
viteConfigEnv,
1024-
viteUserConfig,
1025-
}),
1020+
build:
1021+
ctx.environmentBuildContext?.options.build ??
1022+
(
1023+
await getEnvironmentOptions(
1024+
ctx,
1025+
viteConfigEnv.isSsrBuild ? "ssr" : "client",
1026+
{ viteCommand, viteUserConfig }
1027+
)
1028+
).build,
10261029
};
10271030
},
10281031
async configResolved(resolvedViteConfig) {
@@ -2855,40 +2858,6 @@ async function getEnvironmentOptions(
28552858
return resolver(resolverOptions);
28562859
}
28572860

2858-
async function resolveBuildOptions({
2859-
ctx,
2860-
viteCommand,
2861-
viteConfigEnv,
2862-
viteUserConfig,
2863-
}: {
2864-
ctx: ReactRouterPluginContext;
2865-
viteCommand: Vite.ResolvedConfig["command"];
2866-
viteConfigEnv: Vite.ConfigEnv;
2867-
viteUserConfig: Vite.UserConfig;
2868-
}): Promise<Vite.BuildOptions | undefined> {
2869-
// Handle options injected from `react-router build`
2870-
if (ctx.environmentBuildContext?.options.build) {
2871-
return ctx.environmentBuildContext.options.build;
2872-
}
2873-
2874-
// Handle `vite preview` in SPA mode
2875-
if (viteCommand === "serve" && ctx.reactRouterConfig.ssr === false) {
2876-
return {
2877-
manifest: true,
2878-
outDir: getClientBuildDirectory(ctx.reactRouterConfig),
2879-
};
2880-
}
2881-
2882-
// Otherwise, handle `vite build`
2883-
let environmentOptions = await getEnvironmentOptions(
2884-
ctx,
2885-
viteConfigEnv.isSsrBuild ? "ssr" : "client",
2886-
{ viteCommand, viteUserConfig }
2887-
);
2888-
2889-
return environmentOptions.build;
2890-
}
2891-
28922861
function isNonNullable<T>(x: T): x is NonNullable<T> {
28932862
return x != null;
28942863
}

Diff for: playground/framework-spa/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
},
1313
"dependencies": {
1414
"@react-router/node": "workspace:*",
15+
"isbot": "^5",
1516
"react": "^18.2.0",
1617
"react-dom": "^18.2.0",
1718
"react-router": "workspace:*"

Diff for: pnpm-lock.yaml

+3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)