Skip to content

People are confused by adapter-static #5185

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

Closed
elliott-with-the-longest-name-on-github opened this issue Jun 8, 2022 · 5 comments · Fixed by #5562
Closed

People are confused by adapter-static #5185

elliott-with-the-longest-name-on-github opened this issue Jun 8, 2022 · 5 comments · Fixed by #5562
Labels
feature / enhancement New feature or request
Milestone

Comments

@elliott-with-the-longest-name-on-github
Copy link
Contributor

Describe the problem

I've lost count of the number of times people have asked "why is my adapter-static build output missing index.html" (and other similar questions) in Discord. It's always fixed by either adding config.kit.adapter.fallback = 'foo.html' or config.kit.prerender.default = true. To be clear, this is in the documentation, and not having one of these settings does produce a yellow (?) warning during build, but I've found that people tend to lose the yellow warning in the output from build.

Describe the proposed solution

When trying to run svelte-kit dev or svelte-kit build, throw a full-on, red, crash-the-process error stating:

It looks like you're using adapter-static, but `config.kit.prerender.default` is `false` and `config.kit.adapter.fallback` is missing. 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 <link to FAQ in adapter-static docs about this issue>

Maybe I'm missing some context here, but I don't think there's any case where adapter-static should be run without one of those options set, and the fact that it "works" in dev confuses a lot of people.

Alternatives considered

No response

Importance

would make my life easier

Additional Information

Happy to work on this one if it's a feature we'd actually like to add.

@Mlocik97
Copy link
Contributor

There are use cases when you want to use adapter-static without prerendering or fallback, anyway it's good to warn about this... not throw error.

@furudean
Copy link
Contributor

There are use cases when you want to use adapter-static without prerendering or fallback

When?

@bothness
Copy link

I can second that this has been causing confusion for me. In earlier versions of Adapter Static, it was clear that you can render as a SPA by including config.kit.adapter.fallback, or pre-render all routes by including config.kit.prerender.enabled, but now I get messages suggesting that I need to use "hooks" to render as a SPA, but there isn't any documentation on how to do this.

@Rich-Harris
Copy link
Member

Judging by the emoji reactions, this is something we should do. I also can't think of a situation where you'd want to use adapter-static without either prerendering by default or having a fallback.

@Rich-Harris Rich-Harris added this to the 1.0 milestone Jul 15, 2022
@elliott-with-the-longest-name-on-github
Copy link
Contributor Author

@Rich-Harris Consider it done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature / enhancement New feature or request
Projects
None yet
5 participants