Skip to content

Commit 5633bcf

Browse files
refactor(templates/svelte): put site in SPA mode by default (#883)
1 parent 2027215 commit 5633bcf

File tree

5 files changed

+21
-8
lines changed

5 files changed

+21
-8
lines changed

.changes/svelte-spa.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"create-tauri-app": "patch"
3+
"create-tauri-app-js": "patch"
4+
---
5+
6+
Changed Svelte templates to use `@sveltejs/adapter-static`'s fallback feature instead of disabling SSR per-router, See https://svelte.dev/docs/kit/single-page-apps
7+
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Tauri doesn't have a Node.js server to do proper SSR
2-
// so we will use adapter-static to prerender the app (SSG)
2+
// so we use adapter-static with a fallback to index.html to put the site in SPA mode
3+
// See: https://svelte.dev/docs/kit/single-page-apps
34
// See: https://v2.tauri.app/start/frontend/sveltekit/ for more info
4-
export const prerender = true;
55
export const ssr = false;

templates/template-svelte-ts/svelte.config.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// Tauri doesn't have a Node.js server to do proper SSR
2-
// so we will use adapter-static to prerender the app (SSG)
2+
// so we use adapter-static with a fallback to index.html to put the site in SPA mode
3+
// See: https://svelte.dev/docs/kit/single-page-apps
34
// See: https://v2.tauri.app/start/frontend/sveltekit/ for more info
45
import adapter from "@sveltejs/adapter-static";
56
import { vitePreprocess } from "@sveltejs/vite-plugin-svelte";
@@ -8,7 +9,9 @@ import { vitePreprocess } from "@sveltejs/vite-plugin-svelte";
89
const config = {
910
preprocess: vitePreprocess(),
1011
kit: {
11-
adapter: adapter(),
12+
adapter: adapter({
13+
fallback: "index.html",
14+
}),
1215
},
1316
};
1417

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Tauri doesn't have a Node.js server to do proper SSR
2-
// so we will use adapter-static to prerender the app (SSG)
2+
// so we use adapter-static with a fallback to index.html to put the site in SPA mode
3+
// See: https://svelte.dev/docs/kit/single-page-apps
34
// See: https://v2.tauri.app/start/frontend/sveltekit/ for more info
4-
export const prerender = true;
55
export const ssr = false;

templates/template-svelte/svelte.config.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
// Tauri doesn't have a Node.js server to do proper SSR
2-
// so we will use adapter-static to prerender the app (SSG)
2+
// so we use adapter-static with a fallback to index.html to put the site in SPA mode
3+
// See: https://svelte.dev/docs/kit/single-page-apps
34
// See: https://v2.tauri.app/start/frontend/sveltekit/ for more info
45
import adapter from "@sveltejs/adapter-static";
56

67
/** @type {import('@sveltejs/kit').Config} */
78
const config = {
89
kit: {
9-
adapter: adapter(),
10+
adapter: adapter({
11+
fallback: "index.html",
12+
}),
1013
},
1114
};
1215

0 commit comments

Comments
 (0)