I am currently working on a mini web app and trying to deploy it to a VM. Everything works fine via npm run dev
, but routes do not work when running VS Code live server on the dist after npm run build
or npx serve dist
in the root directory.
The only way I can get any routes besides the root to work is via npx serve dist --single
.
I also want to note that specific route directories are not generated in the dist folder after npm run build
. Here is my current directory structure under src.
src├── app.d.ts├── app.html├── globals.css├── lib│└── components│├── Image.svelte│├── Light.svelte│└── ThreeJSWindow.svelte└── routes├──+layout.svelte├──+page.svelte├── tree│└──+page.svelte└── v1└──+page.svelte
No directories are generated in dist corresponding to the /tree or /v1 routes.
My main goal is to deploy this to a VM as a static html server using nginx without having to configure this as a node server. I tried doing that and could not get it working either.
I figure if I cannot run this app via live server in the dist directory, I should not try deploying it yet.
I originally assumed that this was an issue with my svelte.config.js file, but nothing has worked so far:
import adapter from '@sveltejs/adapter-static';import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';/** @type {import('@sveltejs/kit').Config} */const config = { kit: { adapter: adapter({ pages: 'dist', assets: 'dist', fallback: 'index.html', }), paths: { base: '', }, prerender: { entries: ['*'], }, }, preprocess: vitePreprocess(),};export default config;