Skip to content
Source
Sign inSign up
TanStack/router

fix(start-plugin-core): resolve prerender paths against the Vite root #8872

Openaaronanish-t(GitHub profile, opens in a new tab)wants to merge 2 commits intomain fromrefs/pull/8872/headopened

Showing 9 changed files with 24 additions and 3 deletions (loading 6).

x
0 of 9 viewed, 9 left
5 additions and 0 deletions.changeset/start-prerender-vite-root.mdAdded
View file
@@ -0,0 +1,5 @@
+---
+'@tanstack/start-plugin-core': patch
+---
+​
+Prerendering now uses Vite's `root` when it is not the working directory (`vite build <dir>`, `createBuilder({ root })`): the preview server starts from `root`, and the server and client build outputs are resolved against it instead of `process.cwd()`.
8 additions and 2 deletionspackages/start-plugin-core/src/vite/preview-server-plugin/plugin.tsModified
View file
@@ -3,7 +3,10 @@
import { NodeRequest, sendNodeResponse } from 'srvx/node'
import { joinURL } from 'ufo'
import { VITE_ENVIRONMENT_NAMES } from '../../constants'
-import { getServerOutputDirectory } from '../output-directory'
+import {
+ getServerOutputDirectory,
+ resolveOutputDirectory,
+} from '../output-directory'
import { getBundlerOptions } from '../../utils'
import type { Plugin } from 'vite'
​
@@ -36,7 +39,10 @@
​
// Get basename without extension and add .js
const outputFilename = `${basename(serverInput, extname(serverInput))}.js`
- const serverOutputDir = getServerOutputDirectory(server.config)
+ const serverOutputDir = resolveOutputDirectory(
+ server.config.root,
+ getServerOutputDirectory(server.config),
+ )