Skip to content

Commit d0eac2f

Browse files
committed
fix: stricter html fallback check in transformRequest
ref #2051
1 parent cb83b95 commit d0eac2f

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

packages/vite/src/node/server/transformRequest.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -63,18 +63,18 @@ export async function transformRequest(
6363
const loadStart = isDebug ? Date.now() : 0
6464
const loadResult = await pluginContainer.load(id, ssr)
6565
if (loadResult == null) {
66+
// if this is an html request and there is no load result, skip ahead to
67+
// SPA fallback.
68+
if (options.html && !id.endsWith('.html')) {
69+
return null
70+
}
6671
// try fallback loading it from fs as string
6772
// if the file is a binary, there should be a plugin that already loaded it
6873
// as string
6974
try {
7075
code = await fs.readFile(file, 'utf-8')
7176
isDebug && debugLoad(`${timeFrom(loadStart)} [fs] ${prettyUrl}`)
7277
} catch (e) {
73-
// if this is an html request and there is no load result, skip ahead to
74-
// SPA fallback.
75-
if (options.html) {
76-
return null
77-
}
7878
if (e.code !== 'ENOENT') {
7979
throw e
8080
}

0 commit comments

Comments
 (0)