-
Notifications
You must be signed in to change notification settings - Fork 1
/
next.config.js
146 lines (136 loc) · 4.39 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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
const rewriteConfig = require('./rewrites');
const serverless = {};
if (process.env.SERVERLESS) {
console.log('Serverless target');
serverless.target = 'serverless';
}
module.exports = {
...serverless,
images: {
domains: ['images.fd.nl', 'fd-external-development.imgix.net'],
disableStaticImages: true,
},
async rewrites() {
return [
...rewriteConfig,
{
source: '/colors',
destination:
'https://fdmediagroep.atlassian.net/wiki/spaces/FDMT/pages/771162327/Colors',
},
{
source: '/downloads',
destination: 'https://fdmediagroep.atlassian.net/l/c/0gaajnrZ',
},
];
},
async redirects() {
return [
{
source: '/(verrijking|verijking)',
destination:
'/achtergrond/1324449/alle-verrijking-op-een-rijtje',
permanent: false,
},
];
},
headers() {
return [
{
// Apply these headers to all routes in your application.
source: '/:path*',
headers: [
{
key: 'Content-Security-Policy',
value: "default-src http: https: data: blob: ws: wss: 'unsafe-inline' 'unsafe-eval';"
.replace(/\s{2,}/g, ' ')
.trim(),
},
{
key: 'Referrer-Policy',
value: 'strict-origin-when-cross-origin',
},
{
key: 'strict-transport-security',
value: 'max-age=15724800',
},
{
key: 'X-Content-Type-Options',
value: 'nosniff',
},
{
key: 'X-Frame-Options',
value: 'SAMEORIGIN',
},
],
},
];
},
webpack: (config, options) => {
// Markdown
config.module.rules.push({
test: /\.md$/,
use: ['raw-loader'],
});
// SVG
config.module.rules.unshift({
test: /\.svg$/i,
use: [
{
loader: 'react-svg-loader',
options: {
jsx: false, // true outputs JSX tags
svgo: {
plugins: [
{
removeViewBox: false,
},
],
},
},
},
],
});
/**
* Add custom polyfills if needed.
*/
const originalEntry = config.entry;
config.entry = async () => {
const entries = await originalEntry();
if (
entries['main.js'] &&
!entries['main.js'].includes('./client/polyfills.js')
) {
entries['main.js'].unshift('./client/polyfills.js');
}
return entries;
};
/**
* This config replaces React with PreactX (3KB gzipped).
* PreactX should be a 100% drop-in replacement for React.
* If PreactX is causing problems we can just turn this config off.
*/
// config.resolve.alias = Object.assign({}, config.resolve.alias, {
// react: 'preact/compat',
// react$: 'preact/compat',
// 'react-dom': 'preact/compat',
// 'react-dom$': 'preact/compat',
// });
/**
* Generate webpack bundle report.
*/
if (process.env.WEBPACK_BUNDLE_ANALYZER == 'true') {
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
config.plugins.push(
new BundleAnalyzerPlugin({
analyzerMode: 'static',
reportFilename: options.isServer
? '../../analyzer/server.html'
: '../analyzer/client.html',
openAnalyzer: false,
})
);
}
return config;
},
};