forked from kawalcovid19/wargabantuwarga.com
-
Notifications
You must be signed in to change notification settings - Fork 0
/
next.config.js
91 lines (81 loc) · 2.59 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
const withBundleAnalyzer = require("@next/bundle-analyzer")({
enabled: process.env.ANALYZE === "true",
});
const ContentSecurityPolicy = `
default-src 'self';
script-src 'self' 'unsafe-inline' *.googletagmanager.com 'unsafe-eval';
style-src 'self' 'unsafe-inline';
img-src 'self' blob: data: https:;
frame-ancestors 'none';
`;
/** @type {import("next/dist/lib/config-shared").Header['headers']} */
const securityHeaders = [
{
key: "Content-Security-Policy",
value: ContentSecurityPolicy.replace(/\n/g, ""),
},
{
key: "X-Frame-Options",
value: "DENY",
},
{
key: "X-Content-Type-Options",
value: "nosniff",
},
// Disables camera, microphone, and geolocation.
// `interest-cohort=()` opts the website out of Google's FLoC: https://amifloced.org/
{
key: "Permissions-Policy",
value: "camera=(), microphone=(), geolocation=(), interest-cohort=()",
},
];
/** @type {import("next/dist/next-server/server/config-shared").NextConfig} */
module.exports = withBundleAnalyzer({
// 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,
},
future: {
// @nibraswastaken told me to add this - @resir014
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,
},
];
},
images: {
deviceSizes: [360, 420, 720],
domains: ["firebase-kanvas.imgix.net", "res.cloudinary.com"],
loader: "cloudinary",
path: "https://res.cloudinary.com/wargabantuwarga/image/upload/",
},
// https://nextjs.org/docs/api-reference/next.config.js/react-strict-mode
reactStrictMode: true,
// 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",
});
}
config.module.rules.push({
test: /\.md$/,
use: {
loader: "frontmatter-markdown-loader",
},
});
return config;
},
});