SvelteKit
This guide will go into:
- Minimal Installation Steps - The steps needed to get a minimum Wails setup working for SvelteKit.
- Install Script - Bash script for accomplishing the Minimal Installation Steps with optional Wails branding.
- Important Notes - Issues that can be encountered when using SvelteKit + Wails and fixes.
1. Minimal Installation Steps
Install Wails for Svelte.
wails init -n myapp -t svelte
Delete the svelte frontend.
- Navigate into your newly created myapp folder.
- Delete the folder named "frontend"
While in the Wails project root. Use the Svelte CLI to create a SvelteKit project as the new frontend. Follow the prompts, nothing Wails specific is needed here.
npx sv create frontend
Modify wails.json.
- Add
"wailsjsdir": "./frontend/src/lib",Do note that this is where your Go and runtime functions will appear. - Change your package manager frontend here if not using npm.
Modify main.go.
- The first comment
//go:embed all:frontend/distneeds to be changed to//go:embed all:frontend/build
Modify .gitignore
- The line
frontend/distneeds to be replaced withfrontend/build
Install/remove dependencies using your favorite package manager.
- Navigate into your "frontend" folder.
npm inpm uninstall @sveltejs/adapter-autonpm i -D @sveltejs/adapter-static
Change adapter in svelte.config.js
- First line of file change
import adapter from '@sveltejs/adapter-auto';toimport adapter from '@sveltejs/adapter-static';