Skip to content

Commit

Permalink
[fix] reestablish prerender.enabled option
Browse files Browse the repository at this point in the history
fixes #7899
  • Loading branch information
dummdidumm committed Dec 6, 2022
1 parent a999fce commit cf6f6e3
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/olive-ears-suffer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/kit': patch
---

[fix] reestablish prerender.enabled option
2 changes: 1 addition & 1 deletion packages/kit/src/core/config/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ const get_defaults = (prefix = '') => ({
crawl: true,
createIndexFiles: undefined,
default: undefined,
enabled: undefined,
enabled: true,
entries: ['*'],
force: undefined,
handleHttpError: 'fail',
Expand Down
5 changes: 1 addition & 4 deletions packages/kit/src/core/config/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,10 +238,7 @@ const options = object(
(keypath) =>
`${keypath} has been removed. You can set it inside the top level +layout.js instead. See the PR for more information: https://github.com/sveltejs/kit/pull/6197`
),
enabled: error(
(keypath) =>
`${keypath} has been removed. You can wrap any code that should not be executed during build in a \`if (!building) {...}\` block. See the discussion for more information: https://github.com/sveltejs/kit/discussions/7716`
),
enabled: boolean(true),
entries: validate(['*'], (input, keypath) => {
if (!Array.isArray(input) || !input.every((page) => typeof page === 'string')) {
throw new Error(`${keypath} must be an array of strings`);
Expand Down
5 changes: 5 additions & 0 deletions packages/kit/src/core/prerender/prerender.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@ export async function prerender() {
/** @type {import('types').ValidatedKitConfig} */
const config = (await load_config()).kit;

if (!config.prerender.enabled) {
output_and_exit({ prerendered, prerender_map });
return;
}

/** @type {import('types').Logger} */
const log = logger({
verbose: verbose === 'true'
Expand Down
5 changes: 5 additions & 0 deletions packages/kit/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,11 @@ export interface KitConfig {
* @default true
*/
crawl?: boolean;
/**
* Set this to `false` to disable prerendering altogether
* @default true
*/
enabled?: boolean;
/**
* An array of pages to prerender, or start crawling from (if `crawl: true`). The `*` string includes all non-dynamic routes (i.e. pages with no `[parameters]`, because SvelteKit doesn't know what value the parameters should have).
* @default ["*"]
Expand Down

0 comments on commit cf6f6e3

Please sign in to comment.