-
Notifications
You must be signed in to change notification settings - Fork 160
/
nuxt.config.ts
223 lines (217 loc) · 7.01 KB
/
nuxt.config.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
import { ofetch } from 'ofetch'
import { logger } from '@nuxt/kit'
import { isWindows } from 'std-env'
function normalizedDirPath(path?: string) {
if (!path || !isWindows) {
return path
}
return path.replace(/\\/g, '/')
}
const docsSourceBase = normalizedDirPath(process.env.NUXT_DOCS_PATH)
const examplesSourceBase = normalizedDirPath(process.env.NUXT_EXAMPLES_PATH)
const docsSource: any = {
name: 'nuxt-docs',
driver: 'github',
repo: 'nuxt/nuxt',
branch: '3.x',
dir: 'docs',
prefix: '/1.docs',
token: process.env.NUXT_GITHUB_TOKEN || ''
}
if (docsSourceBase) {
docsSource.driver = 'fs'
docsSource.base = docsSourceBase
}
const examplesSource: any = {
name: 'nuxt-examples',
driver: 'github',
repo: 'nuxt/examples',
branch: 'main',
dir: '.docs',
prefix: '/docs/4.examples',
token: process.env.NUXT_GITHUB_TOKEN || ''
}
if (examplesSourceBase) {
examplesSource.driver = 'fs'
examplesSource.base = examplesSourceBase
}
// https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({
extends: [
process.env.NUXT_UI_PRO_PATH || '@nuxt/ui-pro'
],
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore Type circular reference
modules: [
'nuxt-content-twoslash',
'@nuxt/content',
'@nuxt/ui',
'@nuxt/image',
'@nuxtjs/plausible',
'@nuxt/fonts',
'@nuxt/eslint',
'@nuxt/scripts',
'@nuxtjs/turnstile',
'@nuxthq/studio',
'@vueuse/nuxt',
'nuxt-og-image',
() => {
if (docsSourceBase) {
logger.success(`Using local Nuxt docs from ${docsSourceBase}`)
}
if (examplesSourceBase) {
logger.success(`Using local Nuxt examples from ${examplesSourceBase}`)
}
}
],
$development: {
runtimeConfig: {
public: {
website: {
url: 'http://localhost:3000'
}
}
}
},
$production: {
image: {
ipx: {
baseURL: 'https://ipx.nuxt.com'
}
}
},
devtools: {
enabled: false
},
colorMode: {
preference: 'dark'
},
// image: {
// ipx: {
// baseURL: 'https://ipx.nuxt.com'
// }
// },
content: {
navigation: {
fields: ['titleTemplate']
},
sources: {
docsSource,
examplesSource
},
highlight: {
theme: {
default: 'material-theme-lighter',
dark: 'material-theme-palenight'
},
langs: [
'js',
'ts',
'vue',
'css',
'scss',
'sass',
'html',
'bash',
'md',
'mdc',
'json',
'json5',
'jsonc',
'tsx'
]
}
},
routeRules: {
// Pre-render
'/api/search.json': { prerender: true },
'/api/templates.json': { prerender: true },
'/blog/rss.xml': { prerender: true },
// '/sitemap.xml': { prerender: true },
'/newsletter': { prerender: true },
// Redirects
'/docs': { redirect: '/docs/getting-started/introduction', prerender: false },
'/docs/getting-started': { redirect: '/docs/getting-started/introduction', prerender: false },
'/docs/guide/concepts': { redirect: '/docs/guide/concepts/auto-imports', prerender: false },
'/docs/guide/directory-structure': { redirect: '/docs/guide/directory-structure/app', prerender: false },
'/docs/guide/going-further': { redirect: '/docs/guide/going-further/experimental-features', prerender: false },
'/docs/guide/going-further/edge-release-channel': { redirect: '/docs/guide/going-further/nightly-release-channel', prerender: false },
'/docs/bridge': { redirect: '/docs/bridge/overview', prerender: false },
'/docs/migration': { redirect: '/docs/migration/overview', prerender: false },
'/docs/api/components': { redirect: '/docs/api/components/client-only', prerender: false },
'/docs/api/composables': { redirect: '/docs/api/composables/use-app-config', prerender: false },
'/docs/api/utils': { redirect: '/docs/api/utils/dollarfetch', prerender: false },
'/docs/api/kit': { redirect: '/docs/api/kit/modules', prerender: false },
'/docs/api/commands': { redirect: '/docs/api/commands/dev', prerender: false },
'/docs/api/advanced': { redirect: '/docs/api/advanced/hooks', prerender: false },
'/docs/api/configuration/nuxt-config': { redirect: '/docs/api/nuxt-config', prerender: false },
'/docs/examples': { redirect: '/docs/examples/hello-world', prerender: false },
'/docs/examples/features': { redirect: '/docs/examples/features/auto-imports', prerender: false },
'/docs/examples/routing': { redirect: '/docs/examples/routing/middleware', prerender: false },
'/docs/examples/advanced': { redirect: '/docs/examples/advanced/config-extends', prerender: false },
'/docs/examples/experimental': { redirect: '/docs/examples/experimental/wasm', prerender: false },
'/docs/community': { redirect: '/docs/community/getting-help', prerender: false },
'/docs/community/nuxt-community': { redirect: '/docs/community/getting-help', prerender: false },
'/docs/guide/recipes': { redirect: '/docs/guide/recipes/custom-routing', prerender: false },
'/docs/guide/going-further/custom-routing': { redirect: '/docs/guide/recipes/custom-routing', prerender: false },
// '/docs/guide/directory-structure/nuxt.config': { redirect: '/docs/guide/directory-structure/nuxt-config', prerender: false },
'/enterprise': { redirect: '/enterprise/support', prerender: false }
},
future: {
compatibilityVersion: 4
},
experimental: {
buildCache: false
},
compatibilityDate: '2024-07-18',
nitro: {
prerender: {
// failOnError: false
// TODO: investigate
// Ignore weird url from crawler on some modules readme
ignore: ['/modules/%3C/span', '/modules/%253C/span', '/docs/getting-started/</span', '/docs/getting-started/%3C/span', '/modules/Mojo CSS', '/modules/Mojo%20CSS']
},
hooks: {
'prerender:generate'(route) {
// TODO: fix issue with recursive fetches with query string, e.g.
// `/enterprise/agencies?region=europe&amp;amp;service=ecommerce&amp;service=ecommerce&service=content-marketing`
if (route.route?.includes('&')) {
route.skip = true
}
}
}
},
typescript: {
strict: false
},
hooks: {
async 'prerender:routes'(ctx) {
// Add Nuxt 2 modules to the prerender list
const { modules } = await ofetch<{ modules: [] }>('https://api.nuxt.com/modules?version=2').catch(() => ({ modules: [] }))
for (const module of modules) {
ctx.routes.add(`/modules/${module.name}`)
}
}
},
eslint: {
config: {
stylistic: {
commaDangle: 'never'
}
}
},
icon: {
clientBundle: {
scan: true
}
},
twoslash: {
floatingVueOptions: {
classMarkdown: 'prose prose-primary dark:prose-invert'
},
// Skip Twoslash in dev to improve performance. Turn this on when you want to explictly test twoslash in dev.
enableInDev: false,
// Do not throw when twoslash fails, the typecheck should be down in github.com/nuxt/nuxt's CI
throws: false
}
})