This repository has been archived by the owner on Oct 6, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathnext.config.js
73 lines (66 loc) · 1.86 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
/** @type {import("next/dist/lib/config-shared").Header['headers']} */
const securityHeaders = [
{
key: "Referrer-Policy",
value: "same-origin",
},
{
key: "X-Frame-Options",
value: "DENY",
},
{
key: "X-Content-Type-Options",
value: "nosniff",
},
{
key: "X-XSS-Protection",
value: "1; mode=block",
},
];
/** @type {import("next/dist/next-server/server/config-shared").NextConfig} */
module.exports = {
// https://github.com/vercel/next.js/blob/v11.0.1/packages/next/next-server/server/config-shared.ts#L42-L65
experimental: {
optimizeCss: true,
optimizeImages: true,
workerThreads: true,
},
// https://nextjs.org/docs/advanced-features/customizing-postcss-config
future: {
strictPostcssConfiguration: true,
},
// This config won't be loaded until Netlify supports the `headers` option on `next.config.js`.
// For now, when you make changes here, also make the necessary changes on `netlify.toml`.
// https://github.com/netlify/netlify-plugin-nextjs/issues/150
headers: async () => {
return [
{
source: "/(.*)",
headers: securityHeaders,
},
];
},
// https://nextjs.org/docs/api-reference/next.config.js/react-strict-mode
reactStrictMode: true,
async redirects() {
return [
{
source: "/dashboard",
destination: "/dashboard/tracing",
permanent: false,
},
];
},
// https://nextjs.org/docs/api-reference/next.config.js/custom-webpack-config
webpack(config, { dev, isServer }) {
// https://github.com/leerob/leerob.io/blob/9adc510cbfb3da88c3b0ad15632eb876ca91b607/next.config.js#L27-L33
if (!dev && !isServer) {
Object.assign(config.resolve.alias, {
react: "preact/compat",
"react-dom/test-utils": "preact/test-utils",
"react-dom": "preact/compat",
});
}
return config;
},
};