Skip to content

fix: vite plugin root directory of prerender #13824

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions contributors.yml
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@
- ken0x0a
- kentcdodds
- kettanaito
- kigawas
- kilavvy
- kiliman
- kkirsche
Expand Down
8 changes: 4 additions & 4 deletions packages/react-router-dev/vite/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2650,7 +2650,7 @@ async function handleSpaMode(

// Write out the HTML file for the SPA
await fse.writeFile(path.join(clientBuildDirectory, filename), html);
let prettyDir = path.relative(process.cwd(), clientBuildDirectory);
let prettyDir = path.relative(viteConfig.root, clientBuildDirectory);
let prettyPath = path.join(prettyDir, filename);
if (build.prerender.length > 0) {
viteConfig.logger.info(
Expand Down Expand Up @@ -2824,7 +2824,7 @@ async function prerenderData(
}

// Write out the .data file
let outdir = path.relative(process.cwd(), clientBuildDirectory);
let outdir = path.relative(viteConfig.root, clientBuildDirectory);
let outfile = path.join(outdir, ...normalizedPath.split("/"));
await fse.ensureDir(path.dirname(outfile));
await fse.outputFile(outfile, data);
Expand Down Expand Up @@ -2883,7 +2883,7 @@ async function prerenderRoute(
}

// Write out the HTML file
let outdir = path.relative(process.cwd(), clientBuildDirectory);
let outdir = path.relative(viteConfig.root, clientBuildDirectory);
let outfile = path.join(outdir, ...normalizedPath.split("/"), "index.html");
await fse.ensureDir(path.dirname(outfile));
await fse.outputFile(outfile, html);
Expand Down Expand Up @@ -2916,7 +2916,7 @@ async function prerenderResourceRoute(
}

// Write out the resource route file
let outdir = path.relative(process.cwd(), clientBuildDirectory);
let outdir = path.relative(viteConfig.root, clientBuildDirectory);
let outfile = path.join(outdir, ...normalizedPath.split("/"));
await fse.ensureDir(path.dirname(outfile));
await fse.outputFile(outfile, content);
Expand Down