-
Notifications
You must be signed in to change notification settings - Fork 668
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'v2' into new-cli-commands
- Loading branch information
Showing
4 changed files
with
116 additions
and
18 deletions.
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 |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
"version": "0.0.1", | ||
"scripts": { | ||
"dev:setup:submodules": "git submodule update --init", | ||
"dev:setup:tauri": "yarn --cwd packages/tauri/tooling/api", | ||
"dev:setup:tauri": "pnpm install -C packages/tauri/tooling/api", | ||
"dev:setup:plugins-workspace": "pnpm --prefix packages/plugins-workspace install", | ||
"dev:setup": "pnpm dev:setup:submodules && pnpm dev:setup:tauri && pnpm dev:setup:plugins-workspace", | ||
"dev": "astro dev", | ||
|
@@ -20,11 +20,9 @@ | |
"preview": "astro preview" | ||
}, | ||
"dependencies": { | ||
"@astrojs/markdown-remark": "^4.2.1", | ||
"@astrojs/starlight": "^0.20.1", | ||
"@astrojs/rss": "^4.0.5", | ||
"@astrojs/markdown-remark": "^5.0.0", | ||
"@astrojs/starlight": "^0.22.0", | ||
"@astrojs/rss": "^4.0.5", | ||
"@types/json-schema": "^7.0.15", | ||
"astro": "^4.4.4", | ||
"astro-feelback": "^0.3.4", | ||
|
@@ -38,6 +36,9 @@ | |
"starlight-blog": "^0.7.0", | ||
"starlight-links-validator": "^0.8.0" | ||
}, | ||
"engines": { | ||
"pnpm": "^8.0.0" | ||
}, | ||
"pnpm": { | ||
"patchedDependencies": { | ||
"[email protected]": "patches/[email protected]" | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
108 changes: 108 additions & 0 deletions
108
src/content/docs/start/Frontend Configuration/sveltekit.mdx
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,108 @@ | ||
--- | ||
title: Svelte | ||
i18nReady: true | ||
--- | ||
|
||
import { Tabs, TabItem } from '@astrojs/starlight/components'; | ||
import CommandTabs from '@components/CommandTabs.astro'; | ||
|
||
SvelteKit is a meta-framework for Svelte. Learn more about SvelteKit at https://kit.svelte.dev/. This guide is accurate as of SvelteKit 2.5.7 / Svelte 4.2.15. | ||
|
||
## Checklist | ||
|
||
- Use [SGG](https://kit.svelte.dev/docs/adapter-static) and/or [SPA](https://kit.svelte.dev/docs/single-page-apps) via `static-adapter`. Tauri doesn't support server-based solutions. | ||
- Use `build/` as `frontendDist` in `tauri.conf.json`. | ||
|
||
## Example Configuration | ||
|
||
1. Install `@sveltejs/adapter-static`: | ||
|
||
<CommandTabs | ||
npm="npm install --save-dev @sveltejs/adapter-static" | ||
yarn="yarn add -D @sveltejs/adapter-static" | ||
pnpm="pnpm add -D @sveltejs/adapter-static" | ||
/> | ||
|
||
2. Update Tauri configuration: | ||
|
||
<Tabs> | ||
<TabItem label="npm"> | ||
|
||
```json | ||
// tauri.conf.json | ||
{ | ||
"build": { | ||
"beforeDevCommand": "npm run dev", | ||
"beforeBuildCommand": "npm run build", | ||
"devUrl": "http://localhost:5173", | ||
"frontendDist": "../build" | ||
} | ||
} | ||
``` | ||
|
||
</TabItem> | ||
<TabItem label="yarn"> | ||
|
||
```json | ||
// tauri.conf.json | ||
{ | ||
"build": { | ||
"beforeDevCommand": "yarn dev", | ||
"beforeBuildCommand": "yarn build", | ||
"devUrl": "http://localhost:5173", | ||
"frontendDist": "../build" | ||
} | ||
} | ||
``` | ||
|
||
</TabItem> | ||
<TabItem label="pnpm"> | ||
|
||
```json | ||
// tauri.conf.json | ||
{ | ||
"build": { | ||
"beforeDevCommand": "pnpm dev", | ||
"beforeBuildCommand": "pnpm build", | ||
"devUrl": "http://localhost:5173", | ||
"frontendDist": "../build" | ||
} | ||
} | ||
``` | ||
|
||
</TabItem> | ||
</Tabs> | ||
|
||
3. Update SvelteKit configuration: | ||
|
||
```js title="svelte.config.js" {1} | ||
import adapter from '@sveltejs/adapter-static'; | ||
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte'; | ||
|
||
/** @type {import('@sveltejs/kit').Config} */ | ||
const config = { | ||
// Consult https://kit.svelte.dev/docs/integrations#preprocessors | ||
// for more information about preprocessors | ||
preprocess: vitePreprocess(), | ||
|
||
kit: { | ||
adapter: adapter(), | ||
}, | ||
}; | ||
|
||
export default config; | ||
``` | ||
|
||
4. Disable SSR: | ||
|
||
Lastly, we need to disable SSR and enable prerendering by adding a root `+layout.ts` file (or `+layout.js` if you are not using TypeScript) with these contents: | ||
|
||
```ts | ||
// src/routes/+layout.ts | ||
export const prerender = true; | ||
export const ssr = false; | ||
``` | ||
|
||
Note that `static-adapter` doesn't require you to disable SSR for the whole app but it makes it possible to use APIs that depend on the global window object (like Tauri's API) without [Client-side checks](https://kit.svelte.dev/docs/faq#how-do-i-use-x-with-sveltekit-how-do-i-use-a-client-side-only-library-that-depends-on-document-or-window). | ||
|
||
Furthermore, if you prefer Single-Page Application (SPA) mode over SSG, you can change the adapter configurations and `+layout.ts` according to the [adapter docs](https://kit.svelte.dev/docs/single-page-apps). |