forked from tinacms/tina.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
next.config.js
130 lines (117 loc) · 2.99 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
127
128
129
130
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/**',
},
],
},
async rewrites() {
return [
{
source: '/admin',
destination: '/admin/index.html',
},
]
},
async redirects() {
return [
{
source: '/docs/editing/quick-editing',
destination: '/docs/contextual-editing/react',
permanent: true,
},
{
source: '/docs/editing/click-to-edit',
destination: '/docs/contextual-editing/react',
permanent: true,
},
{
source: '/docs/tinacms-context',
destination: '/docs/contextual-editing/overview',
permanent: true,
},
{
source: '/tinasaurus',
destination: '/blog/tinasaurus-docusaurus-starter/',
permanent: true,
},
{
source: '/tina-cloud/connecting-site/',
destination: '/tina-cloud/overview',
permanent: true,
},
]
},
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,
},
//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,
},
]
},
trailingSlash: true,
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))