Short turorial to deploy Svelte app to GitHub Pages.
Create Svelte app
npm create vite@latest
gh-pages npm packageInstall the gh-pages npm package
$ npm install gh-pages --save-dev
Follow instructions
homepage property to the package.json fileAdd a homepage property in this format*: https://{username}.github.io/{repo-name}
"name": "svelte-app",
"version": "0.1.0",
"homepage": "https://{username}.github.io/{repo-name}",
"private": true,
vite.conf.jsexport default defineConfig({
plugins: [svelte()],
base:"/{repo-name}/"
})
package.json fileAdd a deploy to the scripts object:
"scripts": {
"dev": "vite",
"build": "vite build",
"preview": "vite preview",
"deploy": "gh-pages -d dist"
}
Build and deploy the Svelte app to GitHub Pages
npm run build
npm run deploy