Deploying a SvelteKit app with Static Web Apps
Install adapter-static
(make sure it matches your version of SvelteKit! I’m writing this the day after SvelteKit 2.0 was released, with an updated adapter-static π₯Ά)
npm i -D @sveltejs/adapter-static
Add the adapter to svelte.config.js
import adapter from '@sveltejs/adapter-static';
export default {
kit: {
adapter: adapter({
pages: 'build',
assets: 'build',
fallback: undefined,
precompress: false,
strict: true
})
}
};
Create src/routes/+layout.js
and
export const ssr = false;
export const prerender = true;
Make sure you update your auto-generated GitHub action to use the correct output_location
- name: Build And Deploy
id: builddeploy
uses: Azure/static-web-apps-deploy@v1
with:
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API }}
repo_token: ${{ secrets.GITHUB_TOKEN }}
action: "upload"
app_location: "/path-to-frontend-repo" # App source code path
output_location: "build" # Built app content directory - optional
– via SvelteKit Docs, more SvelteKit Docs, this MS Learn but not this MS Learn