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

vike.config.js #1519

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 5 additions & 17 deletions docs/pages/base-url/+Page.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,10 @@ We can change the Base URL *only* of our assets by using the `baseAssets` config
> The most common use case for using `baseAssets` is when deploying assets to a CDN.

```js
// vite.config.js

import vike from 'vike/plugin'
// vike.config.js

export default {
plugins: [
vike({
baseAssets: 'https://cdn.example.org/my-website-assets/'
})
]
baseAssets: 'https://cdn.example.org/my-website-assets/'
}
```

Expand Down Expand Up @@ -106,17 +100,11 @@ We can do both:
- Change the Base URL of our server using the `baseServer` configuration.

```js
// vite.config.js

import vike from 'vike/plugin'
// vike.config.js

export default {
plugins: [
vike({
baseAssets: 'https://cdn.example.org/my-website-assets/',
baseServer: '/some-base/'
})
]
baseAssets: 'https://cdn.example.org/my-website-assets/',
baseServer: '/some-base/'
}
```

Expand Down
10 changes: 2 additions & 8 deletions docs/pages/disableAutoFullBuild/+Page.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,10 @@ import { Link } from '@brillout/docpress'
Set to `true` to disable the automatic chaining of all build steps.

```js
// vite.config.js

import vike from 'vike/plugin'
// vike.config.js

export default {
plugins: [
vike({
disableAutoFullBuild: true
})
]
disableAutoFullBuild: true
}
```

Expand Down
10 changes: 2 additions & 8 deletions docs/pages/includeAssetsImportedByServer/+Page.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,9 @@ When `includeAssetsImportedByServer` is `true`, then static assets (CSS, images,
It's `true` by default and, in principle, there isn't any reason to disable it. You can however disable it:

```js
// vite.config.js

import vike from 'vike/plugin'
// vike.config.js

export default {
plugins: [
vike({
includeAssetsImportedByServer: false
})
]
includeAssetsImportedByServer: false
}
```
12 changes: 4 additions & 8 deletions docs/pages/pre-rendering/+Page.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,10 @@ Pre-rendering can be used for websites with content that changes only occasional
To opt into pre-rendering:

```js
// vite.config.js

import vike from 'vike/plugin'
// vike.config.js

export default {
plugins: [
vike({ prerender: true })
]
prerender: true
}
```

Expand All @@ -60,13 +56,13 @@ If you pre-render all your pages, then you can use Vite's CLI instead of a serve
You can programmatically invoke the pre-rendering process, see <Link href="/prerender-programmatic" />.

React Example:
- <RepoLink path='/examples/react-full/vite.config.ts' /> (see setting <code>prerender</code> option to `true`)
- <RepoLink path='/examples/react-full/vike.config.ts' /> (see setting <code>prerender</code> option to `true`)
- <RepoLink path='/examples/react-full/pages/hello/+onBeforePrerenderStart.ts' />
- <RepoLink path='/examples/react-full/pages/star-wars/index/+onBeforePrerenderStart.ts' />
- <RepoLink path='/examples/react-full/package.json' /> (see Vite CLI usage)

Vue Example:
- <RepoLink path='/examples/vue-full/vite.config.ts' /> (see setting <code>prerender</code> option to `true`)
- <RepoLink path='/examples/vue-full/vike.config.ts' /> (see setting <code>prerender</code> option to `true`)
- <RepoLink path='/examples/vue-full/pages/hello/+onBeforePrerenderStart.ts' />
- <RepoLink path='/examples/vue-full/pages/star-wars/index/+onBeforePrerenderStart.ts' />
- <RepoLink path='/examples/vue-full/package.json' /> (see Vite CLI usage)
Expand Down
42 changes: 15 additions & 27 deletions docs/pages/prerender/+Page.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,18 @@ import { TextType } from '../settings/TextType'
By default, pre-rendering is disabled. To enable it:

```js
// vite.config.js

import vike from 'vike/plugin'
// vike.config.js

export default {
plugins: [
vike({
// Use default settings:
prerender: true,
// Or set settings:
prerender: {
partial: false,
noExtraDir: false,
parallel: 4,
disableAutoRun: false
}
})
]
// Use the default pre-rendering configuration:
prerender: true,
// Or configure pre-renderering options:
prerender: {
partial: false,
noExtraDir: false,
parallel: 4,
disableAutoRun: false
}
}
```

Expand Down Expand Up @@ -174,19 +168,13 @@ When running `$ vite build`, Vike automatically triggers <Link href="/pre-render
You can disable the automatic triggering:

```js
// vite.config.js

import vike from 'vike/plugin'
// vike.config.js

export default {
plugins: [
vike({
prerender: {
// Stop `$ vite build` from initiating pre-rendering
disableAutoRun: true
}
})
]
prerender: {
// Stop `$ vite build` from initiating pre-rendering
disableAutoRun: true
}
}
```

Expand Down
26 changes: 10 additions & 16 deletions docs/pages/redirects/+Page.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,17 @@ See also:
Permanent redirections (HTTP status code `301`):

```js
// vite.config.js

import vike from 'vike/plugin'
// vike.config.js

export default {
plugins: [
vike({
redirects: {
'/about-us': '/about',
// Parameterized redirections
'/product/@id': '/buy/@id',
// Glob redirections
'/admin/*': '/private/*',
// External redirections
'/admin/*': 'https://admin.example.org/*'
}
})
]
redirects: {
'/about-us': '/about',
// Parameterized redirections
'/product/@id': '/buy/@id',
// Glob redirections
'/admin/*': '/private/*',
// External redirections
'/admin/*': 'https://admin.example.org/*'
}
}
```
20 changes: 7 additions & 13 deletions docs/pages/url-normalization/+Page.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,15 @@ By default, URLs are normalized:
You can configure whether URLs are normalized and whether URLs should end with a trailing slash:

```js
// vite.config.js

import vike from 'vike/plugin'
// vike.config.js

export default {
plugins: [
vike({
// Make URLs end with a trailing slash.
// For example: /some//path -> /some/path/
trailingSlash: true,
// Make URLs end with a trailing slash.
// For example: /some//path -> /some/path/
trailingSlash: true,

// Or completely disable automatic URL normalization.
// For example keep URL /some//path/
disableUrlNormalization: true
})
]
// Or completely disable automatic URL normalization.
// For example keep URL /some//path/
disableUrlNormalization: true
}
```
5 changes: 5 additions & 0 deletions examples/base-url-cdn/vike.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import type { ConfigGlobal } from 'vike/types'

export default {
baseAssets: 'http://localhost:8080/cdn/'
} satisfies ConfigGlobal
7 changes: 1 addition & 6 deletions examples/base-url-cdn/vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,5 @@ import react from '@vitejs/plugin-react'
import vike from 'vike/plugin'

export default {
plugins: [
react(),
vike({
baseAssets: 'http://localhost:8080/cdn/'
})
]
plugins: [react(), vike()]
}
7 changes: 7 additions & 0 deletions examples/base-url-server/vike.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { baseServer, baseAssets } from './base.js'
import type { ConfigGlobal } from 'vike/types'

export default {
baseAssets,
baseServer
} satisfies ConfigGlobal
9 changes: 1 addition & 8 deletions examples/base-url-server/vite.config.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
import react from '@vitejs/plugin-react'
import vike from 'vike/plugin'
import { baseServer, baseAssets } from './base.js'

export default {
plugins: [
react(),
vike({
baseAssets,
baseServer
})
]
plugins: [react(), vike()]
}
3 changes: 3 additions & 0 deletions examples/base-url/vike.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import type { ConfigGlobal } from 'vike/types'

export default { prerender: true } satisfies ConfigGlobal
2 changes: 1 addition & 1 deletion examples/base-url/vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ import vike from 'vike/plugin'

export default {
base: '/some/base-url',
plugins: [react(), vike({ prerender: true })]
plugins: [react(), vike()]
}
3 changes: 3 additions & 0 deletions examples/file-structure-domain-driven/vike.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import type { ConfigGlobal } from 'vike/types'

export default { prerender: true } satisfies ConfigGlobal
2 changes: 1 addition & 1 deletion examples/file-structure-domain-driven/vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ import react from '@vitejs/plugin-react'
import vike from 'vike/plugin'

export default {
plugins: [react(), vike({ prerender: true })]
plugins: [react(), vike()]
}
5 changes: 5 additions & 0 deletions examples/i18n/vike.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import type { ConfigGlobal } from 'vike/types'

export default {
prerender: true
} satisfies ConfigGlobal
7 changes: 1 addition & 6 deletions examples/i18n/vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,5 @@ import react from '@vitejs/plugin-react'
import vike from 'vike/plugin'

export default {
plugins: [
react(),
vike({
prerender: true
})
]
plugins: [react(), vike()]
}
5 changes: 5 additions & 0 deletions examples/path-aliases/vike.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import type { ConfigGlobal } from 'vike/types'

export default {
prerender: true
} satisfies ConfigGlobal
7 changes: 1 addition & 6 deletions examples/path-aliases/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,7 @@ const config: UserConfig = {
'#root': __dirname
}
},
plugins: [
react(),
vike({
prerender: true
})
],
plugins: [react(), vike()],
optimizeDeps: {
include: ['react-dom/client']
}
Expand Down
11 changes: 3 additions & 8 deletions examples/react-full/renderer/+config.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
export { config }

import type { Config } from 'vike/types'

// https://vike.dev/config
export const config = {
const config = {
passToClient: ['someAsyncProps'],
clientRouting: true,
hydrationCanBeAborted: true,
// https://vike.dev/meta
meta: {
Expand Down Expand Up @@ -31,12 +32,6 @@ export const config = {
}
}
}
},
hooksTimeout: {
data: {
error: 30 * 1000,
warning: 10 * 1000
}
}
} satisfies Config

Expand Down
14 changes: 14 additions & 0 deletions examples/react-full/vike.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
export { config }

import type { ConfigGlobal } from 'vike/types'

const config = {
prerender: true,
clientRouting: true,
hooksTimeout: {
data: {
error: 30 * 1000,
warning: 10 * 1000
}
}
} satisfies ConfigGlobal
8 changes: 1 addition & 7 deletions examples/react-full/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,5 @@ import vike from 'vike/plugin'
import { UserConfig } from 'vite'

export default {
plugins: [
vike({
prerender: true
}),
mdx(),
react()
]
plugins: [vike(), mdx(), react()]
} as UserConfig
3 changes: 3 additions & 0 deletions examples/vue-full/vike.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import type { ConfigGlobal } from 'vike/types'

export default { prerender: true } satisfies ConfigGlobal
Loading
Loading