-
-
Notifications
You must be signed in to change notification settings - Fork 173
/
next.config.js
56 lines (52 loc) · 1.37 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
const sanityClient = require('@sanity/client')
const client = sanityClient({
dataset: process.env.NEXT_PUBLIC_SANITY_PROJECT_DATASET,
projectId: process.env.NEXT_PUBLIC_SANITY_PROJECT_ID,
useCdn: process.env.NODE_ENV === 'production',
apiVersion: '2022-08-30',
})
// see breakdown of code bloat
const withBundleAnalyzer = require('@next/bundle-analyzer')({
enabled: process.env.ANALYZE === 'true',
})
// get redirects from Sanity for Vercel
async function fetchSanityRedirects() {
const redirectData = await client.fetch(`
*[_type == "redirect"]{
"source": "/" + from,
"destination": "/" + to,
"permanent": isPermanent
}
`)
return redirectData
}
module.exports = withBundleAnalyzer({
swcMinify: true,
async redirects() {
const sanityRedirects = await fetchSanityRedirects()
return sanityRedirects
},
async headers() {
return [
{
source: '/robots.txt',
headers: [
{
key: 'Content-Security-Policy',
value: "connect-src 'self';",
},
],
},
]
},
images: {
domains: ['i.vimeocdn.com', 'img.youtube.com'],
deviceSizes: [
400, 600, 800, 1000, 1200, 1400, 1600, 1800, 2000, 2200, 2400, 2600, 2800,
3000, 3200, 3400,
],
imageSizes: [
20, 30, 40, 50, 60, 80, 100, 120, 140, 180, 220, 260, 300, 340, 380, 390,
],
},
})