-
Notifications
You must be signed in to change notification settings - Fork 1.6k
/
next.config.js
106 lines (93 loc) · 2.38 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
const MomentLocalesPlugin = require('moment-locales-webpack-plugin')
const withSvgr = require('next-svgr')
require('dotenv').config()
const isStatic = process.env.EXPORT_MODE === 'static'
/**
* @type {import('next').NextConfig}
*/
let extraConfig = {}
if (isStatic) {
console.log('Exporting static site')
extraConfig.output = 'export'
}
const withBundleAnalyzer = require('@next/bundle-analyzer')({
enabled: process.env.ANALYZE === 'true',
})
const dummyMailchimpEndpoint =
'https://theDomainHere.us18.list-manage.com/subscribe/post?u=1512315231252&id=0asd21t12e1'
const config = {
...extraConfig,
images: {
unoptimized: process.env.UNOPTIMIZED_IMAGES === 'true',
remotePatterns: [
{
protocol: 'https',
hostname: 'res.cloudinary.com',
port: '',
pathname: '/forestry-demo/**',
},
{
protocol: "https",
hostname: "assets.tina.io",
port: "",
},
],
},
async rewrites() {
return [
{
source: '/admin',
destination: '/admin/index.html',
},
]
},
env: {
MAILCHIMP_ADDRESS: process.env.MAILCHIMP_ADDRESS || dummyMailchimpEndpoint,
HUBSPOT_TEAMS_FORM_ID: process.env.HUBSPOT_TEAMS_FORM_ID,
HUBSPOT_PORTAL_ID: process.env.HUBSPOT_PORTAL_ID,
GTM_ID: process.env.GTM_ID,
SSW_GTM_ID: process.env.SSW_GTM_ID,
},
//avoiding CORS error, more here: https://vercel.com/support/articles/how-to-enable-cors
async headers() {
const headers = [
{
key: 'Access-Control-Allow-Origin',
value: '*',
},
{
key: 'Access-Control-Allow-Methods',
value: 'GET,OPTIONS,PATCH,DELETE,POST,PUT',
},
{
key: 'Access-Control-Allow-Headers',
value: 'Accept, Content-Length, Content-Type',
},
]
if (process.env.NEXT_PUBLIC_VERCEL_ENV === 'preview') {
headers.push({
key: 'X-Robots-Tag',
value: 'noindex',
})
}
return [
{
source: '/:path*',
headers,
},
]
},
exportPathMap: async function () {
return {}
},
webpack(config) {
config.module.rules.push({
test: /\.md$/,
use: 'raw-loader',
})
config.resolve.fallback = { ...config.resolve.fallback, fs: 'empty' }
config.plugins.push(new MomentLocalesPlugin())
return config
},
}
module.exports = withBundleAnalyzer(withSvgr(config))