generated from Clement-Muth/nextjs13-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
next.config.js
62 lines (54 loc) · 1.31 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
const readEnvironmentVariable = (key, defaultValue = undefined) => {
const value = process.env[key];
if (value === undefined && defaultValue === undefined) {
throw new Error(`The environment variable "${key} is missing".`);
}
if (value === "true") {
return true;
}
if (value === "false") {
return false;
}
return value || defaultValue;
};
/** @type {import('next').NextConfig} */
const nextConfig = () => {
return {
optimizeFonts: true,
compress: true,
reactStrictMode: true,
swcMinify: true,
async headers() {
return [
{
source: "/:all*(webp|svg|jpg|png|woff2|js|css|json)",
locale: false,
headers: [
{
key: "Cache-Control",
value: "public, max-age=86400, must-revalidate"
}
]
}
];
},
typescript: {
ignoreBuildErrors: true
},
env: {
PUBLIC_URL: readEnvironmentVariable("PUBLIC_URL"),
}
};
};
const withBundleAnalyzer = require("@next/bundle-analyzer")({
enabled: false,
openAnalyzer: false
});
const withPWA = require("next-pwa")({
dest: "public",
disable: process.env.NODE_ENV === "development",
register: true,
scope: "/",
sw: "service-worker.js"
});
module.exports = withPWA(withBundleAnalyzer(nextConfig()));