Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: adapter-static throws buildtime error when !config.kit.prerender.default && !adapter.fallback #5562

5 changes: 5 additions & 0 deletions .changeset/eleven-buckets-deny.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/adapter-static': patch
---

[breaking] Throws when correctly configured to run as a static site of a SPA
4 changes: 2 additions & 2 deletions packages/adapter-static/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ export default function (options) {

async adapt(builder) {
if (!options?.fallback && !builder.config.kit.prerender.default) {
builder.log.warn(
'You should set `config.kit.prerender.default` to `true` if no fallback is specified'
throw Error(
"It looks like you're using adapter-static, but `config.kit.prerender.default` is `false` and `fallback` has not been provided as a configuration argument to adapter-static. Either set `config.kit.prerender.default` to true (to statically generate your entire site) or set `config.kit.adapter.fallback` to your desired fallback page (to operate in SPA mode). For more information, check out https://github.com/sveltejs/kit/tree/master/packages/adapter-static#spa-mode"
Rich-Harris marked this conversation as resolved.
Show resolved Hide resolved
);
}

Expand Down
2 changes: 1 addition & 1 deletion packages/kit/test/prerendering/disabled/svelte.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import adapter from '../../../../adapter-static/index.js';
/** @type {import('@sveltejs/kit').Config} */
const config = {
kit: {
adapter: adapter(),
adapter: adapter({ fallback: '200.html' }),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we rename the app from disabled to fallback? This test app looks a bit weird as it doesn't check any of the output or anything

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure, done


prerender: {
enabled: false
Expand Down