-
Notifications
You must be signed in to change notification settings - Fork 1
/
nuxt.config.ts
70 lines (69 loc) · 2.13 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
import { defineNuxtConfig } from 'nuxt/config';
import { writeFile, mkdir } from 'node:fs/promises';
import { default as nuxtIcons } from 'nuxt-icons';
import { default as plausible } from '@nuxtjs/plausible';
import { fetchTranslations } from './src/scripts/fetch-translations';
import { fetchBlogFeed } from './src/scripts/fetch-blog-feed';
import { fetchRedirects } from './src/scripts/fetch-redirects';
import { fetchRoutes } from './src/scripts/fetch-routes';
import { fetchI18nSlugs } from './src/scripts/fetch-i18n-slugs';
export default defineNuxtConfig({
srcDir: 'src',
typescript: {
shim: false,
},
css: [
'@/components/app-core/index.css',
],
nitro: {
prerender: {
crawlLinks: false
}
},
runtimeConfig: {
public: {
datoApiToken: process.env.DATOCMS_API_READ_TOKEN,
baseUrl: process.env.BASE_URL,
previewSecret: process.env.PREVIEW_SECRET
},
},
modules: [
nuxtIcons,
plausible,
],
plausible: {
apiHost: '/mogelijk',
},
hooks: {
'prerender:routes': ({ routes }) => {
fetchRoutes()
.then((generatedRoutes) => {
generatedRoutes.forEach((route) => {
// routes is of type Set, so we need to add each route individually
routes.add(route);
})
})
},
'build:before': () => Promise.all([
fetchTranslations()
.then(async (translations) => {
await mkdir('.cache', { recursive: true });
await writeFile('.cache/ui-translations.json', JSON.stringify(translations));
}),
fetchBlogFeed()
.then(async (blogFeed) => {
await mkdir('./src/public/blog', { recursive: true });
await writeFile('./src/public/blog/feed.json', JSON.stringify(blogFeed));
}),
fetchRedirects()
.then((redirects) => writeFile('./src/public/_redirects', redirects)),
fetchI18nSlugs()
.then(async (data) => {
await mkdir('.cache', { recursive: true });
await writeFile('.cache/i18n-slugs.json', JSON.stringify(data));
}),
])
// hook expects a promise with no return data
.then(() => {}),
},
});