Skip to content

Run sveltekit with vite in dev mode behind nginx ssl proxy.

License

Notifications You must be signed in to change notification settings

mdc-git/ddev-sveltekit

Repository files navigation

ddev-sveltekit

Run sveltekit with vite in dev mode behind nginx ssl proxy.

This is for @sveltejs/kit <= 1.0.0-next.525.

https://github.com/torenware/ddev-viteserve might fit your needs better if you are not using svelte.

Note: This will not install if there is already a src/hooks.server.[jt]s file.

You should review your src/hooks.server.[jt]s file and either remove it or you'd have to adjust all your files manually.

This exposes the debug port of vite on the container port 9229 aswell. To use it, run

ddev viteinspect instead of ddev yarn dev.

What does it do?

  1. Overwrite .ddev/nginx_full/nginx-site.conf to proxy requests to http://localhost:5173 and pass the adjusted origin.
  2. Install a src/hooks.server.js to adjust the origin to DDEV_PRIMARY_URL on outgoing cors requests when using svelte's provided fetch.
  3. Add this src/hooks.server.js to .git/info/exclude.
  4. Install a .ddev/docker-compose.network.yaml to add additional known hosts in the network.
  5. Install a .ddev/docker-compose.debug.yaml to expose the vite debugging port

Sample Usage:

ddev config --auto --omit-containers=db,dba --nodejs-version=16 
mkcert -install
ddev get mdc-git/ddev-sveltekit
ddev viteinspect

Related bugs:

Other resources:

Debugging notes:

  • sveltejs/kit#1144

  • sveltejs/kit#7781

  • vitejs/vite#11780

  • A linux binary of jq and hjson along with a small utility script to attach vscode to containerip:9229 will be installed under .ddev/sveltekit and .ddev/commands/host which will increase the repository size to ~5MB. I need them to rewrite my vscode config. Sorry if that annoys you.

About

Run sveltekit with vite in dev mode behind nginx ssl proxy.

Resources

License

Stars

Watchers

Forks

Packages

No packages published