-
Notifications
You must be signed in to change notification settings - Fork 33
/
next.config.js
115 lines (107 loc) · 2.7 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
const nextEnv = require('next-env');
const dotenvLoad = require('dotenv-load');
const path = require('node:path');
const redirects = require('./redirects');
const withBundleAnalyzer = require('@next/bundle-analyzer')({
enabled: process.env.ANALYZE === 'true',
});
dotenvLoad();
const withNextEnv = nextEnv();
const svgTemplate = (
{ template },
opts,
{ imports, componentName, props, jsx },
) => {
return template.ast`${imports}
const ${componentName} = (${props}) => ${jsx};
export default ${componentName};
`;
};
module.exports = withNextEnv(
withBundleAnalyzer({
async redirects() {
return [
{
source: '/landing-pages/cookieConsent.js',
destination: '/api/cookieConsent',
statusCode: 301,
},
...redirects.map((r) => ({ ...r, statusCode: 301 })),
];
},
async headers() {
return [
{
source: '/(.*)?', // Matches all pages
headers: [
{
key: 'strict-transport-security',
value: 'max-age=63072000; includeSubdomains; preload',
},
{
key: 'x-content-type-options',
value: 'nosniff',
},
{
key: 'content-security-policy',
value:
'frame-ancestors https://datocms.admin.datocms.com https://cms.datocms.com http://localhost:3002 http://localhost:3000 https://plugins-cdn.datocms.com https://get.datocms.com',
},
{
key: 'x-xss-protection',
value: '1; mode=block',
},
],
},
];
},
experimental: {
optimizeCss: {
inlineFonts: true,
preloadFonts: true,
logLevel: 'error',
},
},
images: {
disableStaticImages: true,
remotePatterns: [
{
protocol: 'https',
hostname: 'image.mux.com',
},
],
},
webpack(config) {
config.resolve.modules.push(path.resolve('./'));
config.module.rules.push({
test: /\.svg$/,
issuer: /\.jsx?$/,
include: [path.resolve('./public/images')],
use: [
{
loader: '@svgr/webpack',
options: {
icon: false,
template: svgTemplate,
},
},
],
});
config.module.rules.push({
test: /\.svg$/,
issuer: /\.jsx?$/,
include: [path.resolve('./public/icons')],
use: [
{
loader: '@svgr/webpack',
options: {
icon: true,
template: svgTemplate,
},
},
],
});
return config;
},
}),
);