Skip to content

Commit

Permalink
[fix] fallback should still be generated when prerender is disabled (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Theo-Steiner authored Aug 11, 2021
1 parent 1bed886 commit c3ca3fb
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 16 deletions.
5 changes: 5 additions & 0 deletions .changeset/grumpy-onions-applaud.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@sveltejs/kit": patch
---

[fix] fallback should still be generated when prerender is disabled
16 changes: 11 additions & 5 deletions packages/kit/src/core/adapt/prerender.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ const REDIRECT = 3;
* }} opts
*/
export async function prerender({ cwd, out, log, config, build_data, fallback, all }) {
if (!config.kit.prerender.enabled && !fallback) {
return;
}

__fetch_polyfill();

const dir = resolve_path(cwd, `${SVELTE_KIT}/output`);
Expand Down Expand Up @@ -266,13 +270,15 @@ export async function prerender({ cwd, out, log, config, build_data, fallback, a
}
}

for (const entry of config.kit.prerender.pages) {
if (entry === '*') {
for (const entry of build_data.entries) {
if (config.kit.prerender.enabled) {
for (const entry of config.kit.prerender.pages) {
if (entry === '*') {
for (const entry of build_data.entries) {
await visit(entry, null);
}
} else {
await visit(entry, null);
}
} else {
await visit(entry, null);
}
}

Expand Down
20 changes: 9 additions & 11 deletions packages/kit/src/core/adapt/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,15 @@ export function get_utils({ cwd, config, build_data, log }) {
},

async prerender({ all = false, dest, fallback }) {
if (config.kit.prerender.enabled) {
await prerender({
out: dest,
all,
cwd,
config,
build_data,
fallback,
log
});
}
await prerender({
out: dest,
all,
cwd,
config,
build_data,
fallback,
log
});
}
};
}

0 comments on commit c3ca3fb

Please sign in to comment.