Skip to content

Commit 1a008bd

Browse files
authored
make prerender configurable (#1050)
* make prerender configurable * fix a slew of broken links * add contributor note
1 parent cdcdea6 commit 1a008bd

File tree

13 files changed

+36
-20
lines changed

13 files changed

+36
-20
lines changed

apps/svelte.dev/.env

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,6 @@ SUPABASE_KEY=
33

44
GITHUB_CLIENT_ID=
55
GITHUB_CLIENT_SECRET=
6+
7+
# disable prerendering with `PRERENDER=false pnpm build` — this is useful for speeding up builds when previewing locally
8+
PRERENDER=true

apps/svelte.dev/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,11 @@ When writing content for the tutorial, you need to be aware of the differences o
3535
### Dependencies
3636

3737
If you look in the site's package.json you'll notice several dependencies that don't appear to be used, such as `@testing-library/svelte`. These are present because they're referenced in the docs, and Twoslash needs to be able to find type definitions in order to typecheck snippets. Installing the dependencies was deemed preferable to faking it with `declare module`, since we're liable to end up with fictional types that way.
38+
39+
### Prerendering
40+
41+
Most of the site is prerendered. Since that involves some fairly expensive work, it can take a while. To build the site _without_ prerendering — for example, because you need to debug an issue that's affecting production builds — set the `PRERENDER` environment variable to `false`:
42+
43+
```bash
44+
PRERENDER=false pnpm build
45+
```

apps/svelte.dev/src/routes/(authed)/+layout.server.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import * as session from '$lib/db/session';
22

3+
export const prerender = false;
4+
35
/** @type {import('@sveltejs/adapter-vercel').Config} */
46
export const config = {
57
runtime: 'nodejs20.x' // see https://github.com/sveltejs/svelte/pull/9136

apps/svelte.dev/src/routes/+layout.server.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1+
import { PRERENDER } from '$env/static/private';
12
import { docs, index } from '$lib/server/content';
23
import type { BannerData, NavigationLink } from '@sveltejs/site-kit';
34

5+
// by default, all pages are prerendered
6+
export const prerender = PRERENDER !== 'false';
7+
48
const nav_links: NavigationLink[] = [
59
{
610
title: 'Docs',

apps/svelte.dev/src/routes/+page.server.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

apps/svelte.dev/src/routes/blog/+page.server.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import { blog_posts } from '$lib/server/content';
22

3-
export const prerender = true;
4-
53
export async function load() {
64
const posts = blog_posts
75
.map((document) => ({

apps/svelte.dev/src/routes/blog/[slug]/+page.server.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ import { error } from '@sveltejs/kit';
22
import { blog_posts } from '$lib/server/content';
33
import { render_content } from '$lib/server/renderer';
44

5-
export const prerender = true;
6-
75
export async function load({ params }) {
86
const document = blog_posts.find((document) => document.slug === `blog/${params.slug}`);
97

apps/svelte.dev/src/routes/chat/+server.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
export const prerender = true;
2+
13
export function GET() {
24
return new Response(undefined, {
35
status: 302,

apps/svelte.dev/src/routes/docs/+page.server.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

apps/svelte.dev/src/routes/docs/[...path]/+layout.server.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ import { docs } from '$lib/server/content';
22
import { redirect } from '@sveltejs/kit';
33
import { error } from '@sveltejs/kit';
44

5-
export const prerender = true;
6-
75
export async function load({ params }) {
86
const topic = params.path.split('/')[0];
97
const document = docs.topics[`docs/${topic}`];

0 commit comments

Comments
 (0)