-
Notifications
You must be signed in to change notification settings - Fork 0
/
next.config.js
126 lines (121 loc) · 3.18 KB
/
next.config.js
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
/* eslint-env node */
const withBundleAnalyzer = require('@next/bundle-analyzer')({
enabled: process.env.ANALYZE === 'true',
})
const { getRepositoryName } = require('@prismicio/client')
const prismicConfig = require('./slicemachine.config.json')
const prismicRepositoryName = getRepositoryName(prismicConfig.apiEndpoint)
/**
* All supported locales.
* Prismic locale => user-facing locale
*/
const prismicLocaleMap = {
'nl-nl': 'nl',
}
if (!process.env.NEXT_PUBLIC_PRIMARY_HOST) {
throw new Error('Missing required env var: NEXT_PUBLIC_PRIMARY_HOST')
}
if (!process.env.NEXT_PUBLIC_DEFAULT_LOCALE) {
throw new Error('Missing required env var: NEXT_PUBLIC_DEFAULT_LOCALE')
}
if (!process.env.PAGE_REVALIDATE_INTERVAL) {
throw new Error('Missing required env var: PAGE_REVALIDATE_INTERVAL')
}
/** @type {import('next').NextConfig} */
const nextConfig = withBundleAnalyzer({
reactStrictMode: true,
// Values that can not be different between builds. Most values apply, as most
// values affect the generated pages in one way or another. e.g. the default
// locale affects the generated URLs.
env: {
PRISMIC_REPOSITORY_NAME: prismicRepositoryName,
},
// Values that can be different per instance of the server
serverRuntimeConfig: {
pageRevalidateInterval:
process.env.PAGE_REVALIDATE_INTERVAL === 'false'
? undefined
: Number(process.env.PAGE_REVALIDATE_INTERVAL),
},
publicRuntimeConfig: {
prismicLocaleMap,
},
images: {
remotePatterns: [
{
protocol: 'https',
hostname: 'images.prismic.io',
},
{
protocol: 'https',
hostname: `${prismicRepositoryName}.cdn.prismic.io`,
},
{
protocol: 'https',
hostname: 'prismic-io.s3.amazonaws.com',
},
// Used by Prismic Slice Machine mock data
process.env.NODE_ENV === 'development'
? {
protocol: 'https',
hostname: 'images.unsplash.com',
}
: undefined,
].filter(Boolean),
},
redirects: async () => [
{
source: '/:path*',
has: [{ type: 'host', value: 'www.martijnhols.nl' }],
destination: 'https://martijnhols.nl/:path*',
permanent: true,
},
{
source: '/feed',
destination: '/rss.xml',
permanent: true,
},
{
source: '/rss',
destination: '/rss.xml',
permanent: true,
},
],
rewrites: async () => [
{
source: '/hoi/script.js',
destination:
'https://plausible.io/js/script.tagged-events.outbound-links.js',
},
{
source: '/hoi/event',
destination: 'https://plausible.io/api/event',
},
],
webpack: (config) => {
config.module.rules = [
...config.module.rules,
// Import SVG components as react components
{
test: /\.svg$/i,
issuer: /\.[jt]sx?$/,
use: [
{
loader: '@svgr/webpack',
options: {
typescript: true,
dimensions: false,
},
},
],
},
// Downloadable assets
{
test: /\.(ics|otf|ttf)/,
type: 'asset/resource',
},
]
return config
},
})
module.exports = nextConfig