Skip to content

Commit

Permalink
feat: adapter-static throws buildtime error when `!config.kit.prere…
Browse files Browse the repository at this point in the history
…nder.default && !adapter.fallback` (#5562)

* feat: adapter-static errors with incorrect config

* changeset

* fix: Update caught incorrectly configured test project

* rename disabled test to fallback

* Update packages/adapter-static/index.js

* lockfile

Co-authored-by: Rich Harris <hello@rich-harris.dev>
  • Loading branch information
1 parent 2e9d8fb commit ff2ca89
Show file tree
Hide file tree
Showing 10 changed files with 9 additions and 4 deletions.
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(
'adapter-static requires `config.kit.prerender.default` to be `true` unless you set the `fallback: true` option to create a single-page app. See https://github.com/sveltejs/kit/tree/master/packages/adapter-static#spa-mode for more information'
);
}

Expand Down
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' }),

prerender: {
enabled: false
Expand Down
2 changes: 1 addition & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit ff2ca89

Please sign in to comment.