Skip to content

Commit 80a9868

Browse files
fix: fix output path for spa shell (#5682)
1 parent f325d9a commit 80a9868

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

packages/start-plugin-core/src/prerender.ts

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -207,17 +207,28 @@ export async function prerender({
207207
const contentType = res.headers.get('content-type') || ''
208208
const isImplicitHTML =
209209
!cleanPagePath.endsWith('.html') && contentType.includes('html')
210-
// &&
211-
// !JsonSigRx.test(dataBuff.subarray(0, 32).toString('utf8'))
210+
212211
const routeWithIndex = cleanPagePath.endsWith('/')
213212
? cleanPagePath + 'index'
214213
: cleanPagePath
215214

216-
const htmlPath =
217-
cleanPagePath.endsWith('/') ||
218-
(prerenderOptions.autoSubfolderIndex ?? true)
219-
? joinURL(cleanPagePath, 'index.html')
220-
: cleanPagePath + '.html'
215+
const isSpaShell =
216+
startConfig.spa?.prerender.outputPath === cleanPagePath
217+
218+
let htmlPath: string
219+
if (isSpaShell) {
220+
// For SPA shell, ignore autoSubfolderIndex option
221+
htmlPath = cleanPagePath + '.html'
222+
} else {
223+
if (
224+
cleanPagePath.endsWith('/') ||
225+
(prerenderOptions.autoSubfolderIndex ?? true)
226+
) {
227+
htmlPath = joinURL(cleanPagePath, 'index.html')
228+
} else {
229+
htmlPath = cleanPagePath + '.html'
230+
}
231+
}
221232

222233
const filename = withoutBase(
223234
isImplicitHTML ? htmlPath : routeWithIndex,

0 commit comments

Comments
 (0)