Skip to content

Commit 6bd21c7

Browse files
authored
[fix] prerendering not working with kit.paths.base set. (#2407)
1 parent bc9ece1 commit 6bd21c7

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

.changeset/unlucky-dodos-greet.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@sveltejs/kit': patch
3+
---
4+
5+
Fix prerendering/adapter-static failing when `kit.paths.base` was set.

packages/kit/src/core/adapt/prerender.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -260,16 +260,16 @@ export async function prerender({ cwd, out, log, config, build_data, fallback, a
260260
if (!resolved.startsWith('/') || resolved.startsWith('//')) continue;
261261

262262
const parsed = new URL(resolved, 'http://localhost');
263-
const pathname = decodeURI(parsed.pathname);
263+
const pathname = decodeURI(parsed.pathname).replace(config.kit.paths.base, '');
264264

265-
const file = pathname.replace(config.kit.paths.assets, '').slice(1);
265+
const file = pathname.slice(1);
266266
if (files.has(file)) continue;
267267

268268
if (parsed.search) {
269269
// TODO warn that query strings have no effect on statically-exported pages
270270
}
271271

272-
await visit(pathname.replace(config.kit.paths.base, ''), path);
272+
await visit(pathname, path);
273273
}
274274
}
275275
}

0 commit comments

Comments
 (0)