forked from ndimatteo/HULL
-
Notifications
You must be signed in to change notification settings - Fork 0
/
next.config.js
60 lines (50 loc) · 1.69 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
const sanityClient = require('@sanity/client')
const client = sanityClient({
dataset: process.env.SANITY_PROJECT_DATASET,
projectId: process.env.SANITY_PROJECT_ID,
useCdn: process.env.NODE_ENV === 'production',
apiVersion: '2021-03-25',
})
// 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 data = await client.fetch(
`*[_type == "redirect"]{ from, to, isPermanent }`
)
const redirects = data.map((redirect) => {
return {
source: `/${redirect.from}`,
destination: `/${redirect.to}`,
permanent: redirect.isPermanent,
}
})
return redirects
}
module.exports = withBundleAnalyzer({
env: {
// Needed for Sanity powered data
SANITY_PROJECT_DATASET: process.env.SANITY_PROJECT_DATASET,
SANITY_PROJECT_ID: process.env.SANITY_PROJECT_ID,
SANITY_API_TOKEN: process.env.SANITY_API_TOKEN,
// Needed for Shopify product syncs
SHOPIFY_STORE_ID: process.env.SHOPIFY_STORE_ID,
SHOPIFY_API_TOKEN: process.env.SHOPIFY_API_TOKEN,
// Needed for Klaviyo forms
KLAVIYO_API_KEY: process.env.KLAVIYO_API_KEY,
// Needed for Yotpo reviews
YOTPO_API_KEY: process.env.YOTPO_API_KEY,
YOTPO_SECRET_KEY: process.env.YOTPO_SECRET_KEY,
// Needed for Mailchimp forms
MAILCHIMP_API_KEY: process.env.MAILCHIMP_API_KEY,
MAILCHIMP_SERVER: process.env.MAILCHIMP_SERVER,
// Needed for SendGrid forms
SENDGRID_API_KEY: process.env.SENDGRID_API_KEY,
},
async redirects() {
const sanityRedirects = await fetchSanityRedirects()
return sanityRedirects
},
})