Here we want to deploy a SvelteKit app, which has server-side code or do Server-Side Rendering (SSR) (data endpoints, load
function in components).
For a SvelteKit app which is a pure browser-only SPA or a static website, with no server-side code (as one generated with adapter-static
): you don't need an Azure app service instance, an Azure storage blob container ($web
) is all you need.
Note:
In theory, a Sveltekit app with a server-side should be deployable on the new "Azure Static Webapps" product, but we still need to have a dedicated adapter converting the server code to something compatible with Azure functions.
Unlike a lot of nodeJS/JS projects, when working with SvelteKit you should pay attention to the difference between devDependencies
and dependencies
.
In your dependencies
, you should have everything you need to run your app, browser-side and server-side as well : e.g database libraries, preprocess functions, etc.
Right now, do a npm i @sveltejs/adapter-node@next -D
(adapters are not completly stable), and refer to the adapters doc and adapter-node
doc
Due to the way a SvelteKit project is structured, you'll need to upload your whole project to Kudu (the deployment engine behind Azure App Service). Upon upload, Kudu will do an npm install
and npm run build
.
In your Azure app configuration, adjust the "startup command" to node /home/site/wwwroot/build/
.
You'll find this in Azure Portal, under the "Configuration" pane, in "General settings" tab.
It can also be set using azure CLI:
az webapp config set --startup-file "node /home/site/wwwroot/build/" -g <resource-group-name> -n <webapp-name>
If you changed the config of adapter-node
to output the generated app in another folder, replace build/
by your chosen directory.
(to be enriched / continued)
Cheers!