diff --git a/packages/vite/src/node/preview.ts b/packages/vite/src/node/preview.ts index 1a312700db6fac..d6be4040f7345f 100644 --- a/packages/vite/src/node/preview.ts +++ b/packages/vite/src/node/preview.ts @@ -171,6 +171,7 @@ export async function preview( etag: true, dev: true, single: config.appType === 'spa', + ignores: false, setHeaders(res) { if (headers) { for (const name in headers) { diff --git a/playground/assets/__tests__/assets.spec.ts b/playground/assets/__tests__/assets.spec.ts index af939f028ce660..43a93a19276440 100644 --- a/playground/assets/__tests__/assets.spec.ts +++ b/playground/assets/__tests__/assets.spec.ts @@ -41,15 +41,19 @@ test('should get a 404 when using incorrect case', async () => { 'image/png', ) // fallback to index.html - expect((await fetchPath('ICON.png')).headers.get('Content-Type')).toBe( - isBuild ? 'text/html; charset=utf-8' : 'text/html', + const iconPngResult = await fetchPath('ICON.png') + expect(iconPngResult.headers.get('Content-Type')).toBe( + isBuild ? 'text/html;charset=utf-8' : 'text/html', ) + expect(iconPngResult.status).toBe(200) expect((await fetchPath('bar')).headers.get('Content-Type')).toBe('') // fallback to index.html - expect((await fetchPath('BAR')).headers.get('Content-Type')).toContain( + const barResult = await fetchPath('BAR') + expect(barResult.headers.get('Content-Type')).toContain( isBuild ? 'text/html;charset=utf-8' : 'text/html', ) + expect(barResult.status).toBe(200) }) test('should fallback to index.html when accessing non-existant html file', async () => { diff --git a/playground/legacy/__tests__/legacy.spec.ts b/playground/legacy/__tests__/legacy.spec.ts index 5b1a7aebb7f928..59cdc5a3999504 100644 --- a/playground/legacy/__tests__/legacy.spec.ts +++ b/playground/legacy/__tests__/legacy.spec.ts @@ -52,13 +52,13 @@ test('generates assets', async () => { () => page.textContent('#assets'), isBuild ? [ - 'index: text/html; charset=utf-8', - 'index-legacy: text/html; charset=utf-8', - 'chunk-async: text/html; charset=utf-8', - 'chunk-async-legacy: text/html; charset=utf-8', + 'index: text/html;charset=utf-8', + 'index-legacy: text/html;charset=utf-8', + 'chunk-async: text/html;charset=utf-8', + 'chunk-async-legacy: text/html;charset=utf-8', 'immutable-chunk: application/javascript', 'immutable-chunk-legacy: application/javascript', - 'polyfills-legacy: text/html; charset=utf-8', + 'polyfills-legacy: text/html;charset=utf-8', ].join('\n') : [ 'index: text/html',