···11-{
22- // See https://go.microsoft.com/fwlink/?LinkId=733558
33- // for the documentation about the tasks.json format
44- "version": "2.0.0",
55- "tasks": [
66- {
77- "label": "ui:dev",
88- "type": "shell",
99- // `dev` keeps running in the background
1010- // ideally you should also configure a `problemMatcher`
1111- // see https://code.visualstudio.com/docs/editor/tasks#_can-a-background-task-be-used-as-a-prelaunchtask-in-launchjson
1212- "isBackground": true,
1313- // change this to your `beforeDevCommand`:
1414- "command": "deno",
1515- "args": ["task", "dev"]
1616- },
1717- {
1818- "label": "ui:build",
1919- "type": "shell",
2020- // change this to your `beforeBuildCommand`:
2121- "command": "deno",
2222- "args": ["task", "build"]
2323- }
2424- ]
2525-}
11+{
22+ // See https://go.microsoft.com/fwlink/?LinkId=733558
33+ // for the documentation about the tasks.json format
44+ "version": "2.0.0",
55+ "tasks": [
66+ {
77+ "label": "ui:dev",
88+ "type": "shell",
99+ // `dev` keeps running in the background
1010+ // ideally you should also configure a `problemMatcher`
1111+ // see https://code.visualstudio.com/docs/editor/tasks#_can-a-background-task-be-used-as-a-prelaunchtask-in-launchjson
1212+ "isBackground": true,
1313+ // change this to your `beforeDevCommand`:
1414+ "command": "deno",
1515+ "args": ["task", "dev"]
1616+ },
1717+ {
1818+ "label": "ui:build",
1919+ "type": "shell",
2020+ // change this to your `beforeBuildCommand`:
2121+ "command": "deno",
2222+ "args": ["task", "build"]
2323+ }
2424+ ]
2525+}
+11-7
README.md
···11-# Tauri + SvelteKit + TypeScript
22-33-This template should help get you started developing with Tauri, SvelteKit and TypeScript in Vite.
44-55-## Recommended IDE Setup
66-77-[VS Code](https://code.visualstudio.com/) + [Svelte](https://marketplace.visualstudio.com/items?itemName=svelte.svelte-vscode) + [Tauri](https://marketplace.visualstudio.com/items?itemName=tauri-apps.tauri-vscode) + [rust-analyzer](https://marketplace.visualstudio.com/items?itemName=rust-lang.rust-analyzer).
11+# Tauri + SvelteKit + TypeScript
22+33+This template should help get you started developing with Tauri, SvelteKit and
44+TypeScript in Vite.
55+66+## Recommended IDE Setup
77+88+[VS Code](https://code.visualstudio.com/) +
99+[Svelte](https://marketplace.visualstudio.com/items?itemName=svelte.svelte-vscode) +
1010+[Tauri](https://marketplace.visualstudio.com/items?itemName=tauri-apps.tauri-vscode) +
1111+[rust-analyzer](https://marketplace.visualstudio.com/items?itemName=rust-lang.rust-analyzer).
···11-import "../app.css";
22-import { debounce } from "@std/async";
33-import { saveWindowState, StateFlags } from "@tauri-apps/plugin-window-state";
44-import { listen, type Event, TauriEvent } from "@tauri-apps/api/event";
55-66-// Tauri doesn't have a Node.js server to do proper SSR
77-// so we use adapter-static with a fallback to index.html to put the site in SPA mode
88-// See: https://svelte.dev/docs/kit/single-page-apps
99-// See: https://v2.tauri.app/start/frontend/sveltekit/ for more info
1010-export const ssr = false;
1111-1212-const debounced = debounce((_: Event<TauriEvent.WINDOW_RESIZED>) => {
1313- saveWindowState(StateFlags.ALL);
1414-}, 250);
1515-1616-listen("tauri://resize", debounced);
11+import { debounce } from "@std/async";
22+import { saveWindowState, StateFlags } from "@tauri-apps/plugin-window-state";
33+import { type Event, listen, TauriEvent } from "@tauri-apps/api/event";
44+55+// Tauri doesn't have a Node.js server to do proper SSR
66+// so we use adapter-static with a fallback to index.html to put the site in SPA mode
77+// See: https://svelte.dev/docs/kit/single-page-apps
88+// See: https://v2.tauri.app/start/frontend/sveltekit/ for more info
99+export const ssr = false;
1010+1111+const debounced = debounce((_: Event<TauriEvent.WINDOW_RESIZED>) => {
1212+ saveWindowState(StateFlags.ALL);
1313+}, 250);
1414+1515+listen("tauri://resize", debounced);
···11-// Tauri doesn't have a Node.js server to do proper SSR
22-// so we use adapter-static with a fallback to index.html to put the site in SPA mode
33-// See: https://svelte.dev/docs/kit/single-page-apps
44-// See: https://v2.tauri.app/start/frontend/sveltekit/ for more info
55-import adapter from "@sveltejs/adapter-static";
66-import { vitePreprocess } from "@sveltejs/vite-plugin-svelte";
77-88-/** @type {import('@sveltejs/kit').Config} */
99-const config = {
1010- preprocess: vitePreprocess(),
1111- kit: {
1212- adapter: adapter({
1313- fallback: "index.html",
1414- }),
1515- },
1616-};
1717-1818-export default config;
11+// Tauri doesn't have a Node.js server to do proper SSR
22+// so we use adapter-static with a fallback to index.html to put the site in SPA mode
33+// See: https://svelte.dev/docs/kit/single-page-apps
44+// See: https://v2.tauri.app/start/frontend/sveltekit/ for more info
55+import adapter from "npm:@sveltejs/adapter-static";
66+import { vitePreprocess } from "npm:@sveltejs/vite-plugin-svelte";
77+88+/** @type {import('@sveltejs/kit').Config} */
99+const config = {
1010+ preprocess: vitePreprocess(),
1111+ kit: {
1212+ adapter: adapter({
1313+ fallback: "index.html",
1414+ }),
1515+ },
1616+};
1717+1818+export default config;
+19-19
tsconfig.json
···11-{
22- "extends": "./.svelte-kit/tsconfig.json",
33- "compilerOptions": {
44- "allowJs": true,
55- "checkJs": true,
66- "esModuleInterop": true,
77- "forceConsistentCasingInFileNames": true,
88- "resolveJsonModule": true,
99- "skipLibCheck": true,
1010- "sourceMap": true,
1111- "strict": true,
1212- "moduleResolution": "bundler"
1313- }
1414- // Path aliases are handled by https://svelte.dev/docs/kit/configuration#alias
1515- // except $lib which is handled by https://svelte.dev/docs/kit/configuration#files
1616- //
1717- // If you want to overwrite includes/excludes, make sure to copy over the relevant includes/excludes
1818- // from the referenced tsconfig.json - TypeScript does not merge them in
1919-}
11+{
22+ "extends": "./.svelte-kit/tsconfig.json",
33+ "compilerOptions": {
44+ "allowJs": true,
55+ "checkJs": true,
66+ "esModuleInterop": true,
77+ "forceConsistentCasingInFileNames": true,
88+ "resolveJsonModule": true,
99+ "skipLibCheck": true,
1010+ "sourceMap": true,
1111+ "strict": true,
1212+ "moduleResolution": "bundler"
1313+ }
1414+ // Path aliases are handled by https://svelte.dev/docs/kit/configuration#alias
1515+ // except $lib which is handled by https://svelte.dev/docs/kit/configuration#files
1616+ //
1717+ // If you want to overwrite includes/excludes, make sure to copy over the relevant includes/excludes
1818+ // from the referenced tsconfig.json - TypeScript does not merge them in
1919+}
+34-34
vite.config.js
···11-import { defineConfig } from "vite";
22-import { sveltekit } from "@sveltejs/kit/vite";
33-import deno from "@deno/vite-plugin";
44-import tailwindcss from "@tailwindcss/vite";
55-66-// @ts-expect-error process is a nodejs global
77-const host = Deno.env.get("TAURI_DEV_HOST");
88-99-// https://vite.dev/config/
1010-export default defineConfig(async () => ({
1111- plugins: [sveltekit(), tailwindcss(), deno()],
1212-1313- // Vite options tailored for Tauri development and only applied in `tauri dev` or `tauri build`
1414- //
1515- // 1. prevent Vite from obscuring rust errors
1616- clearScreen: false,
1717- // 2. tauri expects a fixed port, fail if that port is not available
1818- server: {
1919- port: 1420,
2020- strictPort: true,
2121- host: host || false,
2222- hmr: host
2323- ? {
2424- protocol: "ws",
2525- host,
2626- port: 1421,
2727- }
2828- : undefined,
2929- watch: {
3030- // 3. tell Vite to ignore watching `src-tauri` and jujutsu directory
3131- ignored: ["**/src-tauri/**", "**/.jj/**"],
3232- },
3333- },
3434-}));
11+import { defineConfig } from "vite";
22+import { sveltekit } from "@sveltejs/kit/vite";
33+import deno from "@deno/vite-plugin";
44+import tailwindcss from "@tailwindcss/vite";
55+66+// @ts-expect-error process is a nodejs global
77+const host = Deno.env.get("TAURI_DEV_HOST");
88+99+// https://vite.dev/config/
1010+export default defineConfig(async () => ({
1111+ plugins: [sveltekit(), tailwindcss(), deno()],
1212+1313+ // Vite options tailored for Tauri development and only applied in `tauri dev` or `tauri build`
1414+ //
1515+ // 1. prevent Vite from obscuring rust errors
1616+ clearScreen: false,
1717+ // 2. tauri expects a fixed port, fail if that port is not available
1818+ server: {
1919+ port: 1420,
2020+ strictPort: true,
2121+ host: host || false,
2222+ hmr: host
2323+ ? {
2424+ protocol: "ws",
2525+ host,
2626+ port: 1421,
2727+ }
2828+ : undefined,
2929+ watch: {
3030+ // 3. tell Vite to ignore watching `src-tauri` and jujutsu directory
3131+ ignored: ["**/src-tauri/**", "**/.jj/**"],
3232+ },
3333+ },
3434+}));