From e1e86b690474e665e7e0fe3b312343fccf0016bf Mon Sep 17 00:00:00 2001 From: Romuald Brillout Date: Thu, 29 Feb 2024 13:27:49 +0100 Subject: [PATCH] fix rebase --- .../prerender-programmatic.page.server.mdx | 95 ------------------- 1 file changed, 95 deletions(-) delete mode 100644 docs/pages/prerender-programmatic.page.server.mdx diff --git a/docs/pages/prerender-programmatic.page.server.mdx b/docs/pages/prerender-programmatic.page.server.mdx deleted file mode 100644 index 9a1e5d26fe5..00000000000 --- a/docs/pages/prerender-programmatic.page.server.mdx +++ /dev/null @@ -1,95 +0,0 @@ -import { Warning, Link } from '@brillout/docpress' - -> See for an overview of what pre-rendering is and how to enable it. - -Pre-rendering is automatically initiated when running `$ vite build`. (If .) - -Instead, we can programmatically initiate pre-rendering: - -```js -// vike.config.js - -export default { - prerender: { - // Stop `$ vite build` from initiating pre-rendering - disableAutoRun: true - } -} -``` - -```js -// my-custom-build-script.js - -import { prerender } from 'vike/prerender' - -// Without options -prerender() - -// All options are optional -prerender({ - pageContextInit, - viteConfig, - onPagePrerender -}) -``` - - -## `pageContextInit` - -The initial value of each page's `pageContext` object. - -```js -prerender({ - pageContextInit: { - someData: 42, - // ... - } -}) -``` - -## `viteConfig` - -The Vite config. - -It's optional: if omitted, Vite automatically loads our `vite.config.js`. - -We recommend to either omit this option or set it to `prerender({ viteConfig: { root }})`: the `vite.config.js` file living at `root` will be loaded. - -Alternatively you can: - - Set: - ```js - prerender({ - viteConfig: { - configFile: require.resolve('./path/to/vite.config.js') - } - }) - ``` - - Not load any `vite.config.js` file and, instead, use `prerender({ viteConfig: { configFile: false, ...myViteConfig }})` to programmatically define the entire Vite config. - -You can also load a `vite.config.js` file while overriding parts of the Vite config. - -See [Vite > JavaScript API > `InlineConfig`](https://vitejs.dev/guide/api-javascript.html#inlineconfig). - - -## `onPagePrerender()` - -DON'T use this option without having contacted a Vike maintainer: this functionality may be completely changed/removed at any time if you don't. - -This feature is experimental and may be changed in any minor version update. - -The `onPagePrerender` option allows us to override where the HTML is written. - -```js -prerender({ - // If we provide `onPagePrerender` then Vike won't write the HTML to the filesystem - onPagePrerender(pageContext) { - // TODO: write the HTML to the filesystem. - // ... - } -}) -``` - - -## More configs - -For more configurations, see the global config at .