Skip to content

Commit 40eff89

Browse files
committed
use absolute paths for prerender files
1 parent f14af14 commit 40eff89

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

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

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2835,12 +2835,13 @@ async function prerenderData(
28352835
}
28362836

28372837
// Write out the .data file
2838-
let outdir = path.relative(viteConfig.root, clientBuildDirectory);
2839-
let outfile = path.join(outdir, ...normalizedPath.split("/"));
2838+
let outfile = path.join(clientBuildDirectory, ...normalizedPath.split("/"));
28402839
await mkdir(path.dirname(outfile), { recursive: true });
28412840
await writeFile(outfile, data);
28422841
viteConfig.logger.info(
2843-
`Prerender (data): ${prerenderPath} -> ${colors.bold(outfile)}`
2842+
`Prerender (data): ${prerenderPath} -> ${colors.bold(
2843+
path.relative(viteConfig.root, outfile)
2844+
)}`
28442845
);
28452846
return data;
28462847
}
@@ -2894,12 +2895,17 @@ async function prerenderRoute(
28942895
}
28952896

28962897
// Write out the HTML file
2897-
let outdir = path.relative(viteConfig.root, clientBuildDirectory);
2898-
let outfile = path.join(outdir, ...normalizedPath.split("/"), "index.html");
2898+
let outfile = path.join(
2899+
clientBuildDirectory,
2900+
...normalizedPath.split("/"),
2901+
"index.html"
2902+
);
28992903
await mkdir(path.dirname(outfile), { recursive: true });
29002904
await writeFile(outfile, html);
29012905
viteConfig.logger.info(
2902-
`Prerender (html): ${prerenderPath} -> ${colors.bold(outfile)}`
2906+
`Prerender (html): ${prerenderPath} -> ${colors.bold(
2907+
path.relative(viteConfig.root, outfile)
2908+
)}`
29032909
);
29042910
}
29052911

@@ -2927,12 +2933,13 @@ async function prerenderResourceRoute(
29272933
}
29282934

29292935
// Write out the resource route file
2930-
let outdir = path.relative(viteConfig.root, clientBuildDirectory);
2931-
let outfile = path.join(outdir, ...normalizedPath.split("/"));
2936+
let outfile = path.join(clientBuildDirectory, ...normalizedPath.split("/"));
29322937
await mkdir(path.dirname(outfile), { recursive: true });
29332938
await writeFile(outfile, content);
29342939
viteConfig.logger.info(
2935-
`Prerender (resource): ${prerenderPath} -> ${colors.bold(outfile)}`
2940+
`Prerender (resource): ${prerenderPath} -> ${colors.bold(
2941+
path.relative(viteConfig.root, outfile)
2942+
)}`
29362943
);
29372944
}
29382945

0 commit comments

Comments
 (0)