-
Notifications
You must be signed in to change notification settings - Fork 31
/
next.config.js
77 lines (69 loc) · 1.84 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
const fs = require('fs')
const dotenv = require('dotenv')
const withTM = require('next-transpile-modules')(['@codegouvfr/react-dsfr'])
const withBundleAnalyzer = require('@next/bundle-analyzer')({
enabled: process.env.ANALYZE === 'true'
})
const imagesDomains = ['static.data.gouv.fr']
const defaultEnvVarFile = '.env.default'
const defaultEnvVarRaw = dotenv.parse(fs.readFileSync(defaultEnvVarFile))
const defaultEnvVar = Object.fromEntries(Object.entries(defaultEnvVarRaw).filter(([key]) => key.startsWith('NEXT_PUBLIC')))
const envVar = Object.fromEntries(
Object
.entries(process.env)
.filter(([key]) => key.startsWith('NEXT_PUBLIC'))
)
if (envVar.NEXT_PUBLIC_GHOST_URL_IMAGES_SOURCE) {
imagesDomains.push(envVar.NEXT_PUBLIC_GHOST_URL_IMAGES_SOURCE)
}
const redirection = async () => [
{
source: '/donnees-nationales/reutilisateurs',
destination: '/donnees-nationales/usages',
permanent: true
},
{
source: '/donnees-nationales/utilisateurs',
destination: '/donnees-nationales/usages',
permanent: true
},
{
source: '/donnees-nationales/base-usages',
destination: '/donnees-nationales/usages',
permanent: true
},
{
source: '/indicateurs',
destination: '/stats',
permanent: true
}
]
const rewritedURL = async () => [
{
source: '/data/ban/adresses-odbl/:path*',
destination: '/data/ban/adresses/:path*',
}
]
const nextConfig = withTM({
images: {
domains: imagesDomains
},
compiler: {
styledComponents: true
},
webpack: config => {
config.module.rules.push({
test: /\.woff2$/,
type: 'asset/resource'
})
return config
},
redirects: redirection,
rewrites: rewritedURL,
publicRuntimeConfig: {
isDevMode: process.env.NODE_ENV !== 'production',
...defaultEnvVar,
...envVar,
},
})
module.exports = withBundleAnalyzer(nextConfig)