-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathnext.config.js
83 lines (75 loc) · 2.07 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
const dotcmsUrl = new URL(process.env.NEXT_PUBLIC_DOTCMS_HOST).hostname
const nextjsUrl = new URL(process.env.NEXT_PUBLIC_DEPLOY_URL).hostname
// Provide domains for local images or in DotCMS CDN
const domains = Array.from(new Set([dotcmsUrl, nextjsUrl]))
/** @type {import('next').NextConfig} */
const nextConfig = {
// Needs to be false due a problem with `styled-components`
// See more information here: https://github.com/styled-components/styled-components/issues/3146#issuecomment-895245050
reactStrictMode: false,
swcMinify: true,
compiler: {
// see https://styled-components.com/docs/tooling#babel-plugin for more info on the options.
styledComponents: true
},
i18n: {
locales: ['en', 'es'],
defaultLocale: 'en',
},
images: {
domains,
},
async headers() {
return [
{
source: '/:path*',
headers: [
{
// Prevent CORS issues in the DotCMS Page Editor
key: 'Access-Control-Allow-Origin',
value: '*',
},
],
},
]
},
async rewrites() {
const baseUrl = process.env.NEXT_PUBLIC_DOTCMS_HOST
return [
// check if Next.js project routes match before we attempt proxying
{
source: '/dA/:slug*',
destination: `${baseUrl}/dA/:slug*`,
},
{
source: '/dotcms-webcomponents/:slug*',
destination: `${baseUrl}/dotcms-webcomponents/:slug*`,
},
{
source: '/api/:slug*',
destination: `${baseUrl}/api/:slug*`,
},
{
source: '/images/:slug*',
destination: `${baseUrl}/images/:slug*`,
},
]
},
webpack: (config) => {
config.module.rules.push({
test: /\.(eot|woff|woff2|ttf|svg|png|jpg|gif)$/,
use: {
loader: 'url-loader',
options: {
limit: 100000,
name: '[name].[ext]',
},
},
})
return config
},
// When we load the page in the DotCMS editor we need to have
// absolutes url for he nextjs page
assetPrefix: process.env.NEXT_PUBLIC_DEPLOY_URL,
}
module.exports = nextConfig