Short turorial to deploy Svelte app to GitHub Pages.
Create Svelte app
npm create vite@latest
Install the gh-pages
npm package
$ npm install gh-pages --save-dev
Follow instructions
Add 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,
export default defineConfig({
plugins: [svelte()],
base:"/{repo-name}/"
})
Add 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