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

adapter-static does not create the fallback file when prerender.enabled = false #4441

Closed
dimfeld opened this issue Mar 24, 2022 · 2 comments · Fixed by #4443
Closed

adapter-static does not create the fallback file when prerender.enabled = false #4441

dimfeld opened this issue Mar 24, 2022 · 2 comments · Fixed by #4443

Comments

@dimfeld
Copy link
Contributor

dimfeld commented Mar 24, 2022

Describe the bug

With config like this, the fallback file is not created:

 import adapter from '@sveltejs/adapter-static';

export default {
 adapter: adapter({
   fallback: 'index.html'
 }),
 prerender: {
   enabled: false,
 },
}

Reproduction

https://stackblitz.com/edit/sveltejs-kit-template-default-hhb1ve?file=package.json

Run npm run build and notice that build/index.html does not exist. I suspect this changed with the recent "prerender during build" PR. It was working with kit version 288 and adapter-static 28.

Logs

No response

System Info

kit 303, adapter-static 29

Severity

blocking an upgrade

Additional Information

No response

@dimfeld
Copy link
Contributor Author

dimfeld commented Mar 24, 2022

Looks like

if (!config.kit.prerender.enabled) {
return prerendered;
}
checked if fallback was set before #4192 but now it doesn't.

@dimfeld
Copy link
Contributor Author

dimfeld commented Mar 24, 2022

I tried making a change to move the fallback creation from the bottom of the function to just after where server is created, and then moved the prerender.enabled check to just after that.

This appears to work fine in my testing. Any thoughts on this?

 const server = new Server(manifest);

 const rendered = await server.respond(new Request('http://sveltekit-prerender/[fallback]'), {
         getClientAddress,
         prerender: {
                 fallback: true,
                 default: false,
                 dependencies: new Map()
         }
 });

 const file = `${config.kit.outDir}/output/prerendered/fallback.html`;
 mkdirp(dirname(file));
 writeFileSync(file, await rendered.text());


 if (!config.kit.prerender.enabled) {
         return prerendered;
 }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant