`vite preview` serves .svelte-kit, not build, leading to incorrect behaviour with `adapter-static`
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 20.8k
- Forks
- 2.3k
- Avg merge
- 1d 16h
- Merged PRs (30d)
- 156
Description
Describe the bug
The docs explain that npm run preview should be used after npm run build, however, at least in the case of adapter-static the behaviour is different – the generated things in .svelte-kit are served instead leading to very different behaviour, for example with routes and error handling (e.g. in a static build any missing route goes to the fallback page, no matter if there's a matcher or not).
There is a partial workaround by using the serve package and replacing vite preview with serve build, but that is only a partial solution as it doesn't support base paths, has a different HTTPS setup, and the like.
Potentially related to https://github.com/sveltejs/kit/issues/3535
Logs
No response
System Info
System:
OS: Windows 10 10.0.22621
CPU: (16) x64 Intel(R) Core(TM) i9-9900K CPU @ 3.60GHz
Memory: 34.88 GB / 63.85 GB
Binaries:
Node: 18.13.0 - C:\Program Files\nodejs\node.EXE
Yarn: 1.22.19 - ~\AppData\Roaming\npm\yarn.CMD
npm: 8.5.0 - C:\Program Files\nodejs\npm.CMD
Browsers:
Edge: Spartan (44.22621.2134.0), Chromium (116.0.1938.69)
Internet Explorer: 11.0.22621.1
Severity
annoyance
Additional Information
The last thing npm run build logs is:
Run npm run preview to preview your production build locally.
which is not really true given these limitations.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue with adapter-static by running npm run build followed by npm run preview, then compare the result with serve build, especially fallback routing and base paths. Start at the vite preview entry point and the adapter-static build output; done means preview serves the production build with matching route, error-handling, base-path, and HTTPS behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, vite
- Domain
- build-system, web-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100