Skip to content

Instantly share code, notes, and snippets.

@lnfel
Created July 3, 2024 06:55
Show Gist options
  • Save lnfel/0b91352fe3bee4757edf7925b4e30ccb to your computer and use it in GitHub Desktop.
Save lnfel/0b91352fe3bee4757edf7925b4e30ccb to your computer and use it in GitHub Desktop.
Notes on deploying sveltekit to Github Pages
  • Use adapter static and add fallback option in svelte.config.js:
adapter: adapter({
    fallback: 'index.html'
}),
  • Configure the paths in svelte.config.js:
paths: {
    base: process.argv.includes('dev') ? '' : '/repo-name'
},
  • Handle any prerendering error:
prerender: {
    handleMissingId: 'warn',
    // other options
}
  • Set prerender option to true in root +layout.ts.
  • Append base path to all of internal urls, links and asset loading.
  • Add .nojekyll file in static folder.
  • When using tailwind background with arbiraty image url always prepend the url with /:
<div class="bg-[url('/img/pagoda.png')]"></div>
  • If doing an SPA (no prerender), set ssr option to false on root +layout.ts:
export const ssr = false

Setting ssr to false will make load functions run only in the client.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment