forked from vitejs/vite
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add an option to turn off the SPA behavior
Fixes vitejs#5720
- Loading branch information
Showing
6 changed files
with
53 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// note: tests should retrieve the element at the beginning of test and reuse it | ||
// in later assertions to ensure CSS HMR doesn't reload the page | ||
|
||
const assertNotIndexHtml = async (path: string) => { | ||
await page.goto(viteTestUrl + path) | ||
const html = await page.innerHTML('body') | ||
expect(html).not.toContain( | ||
`This file should only ever be served as /index.html` | ||
) | ||
} | ||
test('/index.html is served', async () => { | ||
await page.goto(viteTestUrl + '/index.html') | ||
const html = await page.innerHTML('body') | ||
expect(html).toContain(`This file should only ever be served as /index.html`) | ||
}) | ||
test('/ is not served', async () => { | ||
await assertNotIndexHtml('/') | ||
}) | ||
test('/foo/ is not served', async () => { | ||
await assertNotIndexHtml('/foo/') | ||
}) | ||
test('/foo/index.html is not served', async () => { | ||
await assertNotIndexHtml('/foo/index.html') | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<p>Hello</p> | ||
|
||
<p>This file should only ever be served as /index.html in serve mode</p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
// Intentionally empty as no setup is needed |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"name": "nospa", | ||
"private": true, | ||
"version": "0.0.0", | ||
"scripts": { | ||
"dev": "vite", | ||
"build": "vite build", | ||
"debug": "node --inspect-brk ../../vite/bin/vite", | ||
"preview": "vite preview" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module.exports = { | ||
build: { | ||
outDir: './dist', | ||
emptyOutDir: true | ||
}, | ||
server: { | ||
noSpa: true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters