-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathnext.config.js
More file actions
74 lines (70 loc) · 1.98 KB
/
next.config.js
File metadata and controls
74 lines (70 loc) · 1.98 KB
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
/** @type {import('next').NextConfig} */
const webpack = require("webpack");
const buildTimestamp = Date.now().toString();
const withPWA = require("@ducanh2912/next-pwa").default({
dest: "public",
cacheOnFrontEndNav: true,
aggressiveFrontEndNavCaching: true,
reloadOnOnline: true,
disable: process.env.NODE_ENV === "development",
workboxOptions: {
disableDevLogs: true,
skipWaiting: true,
clientsClaim: true,
offlineGoogleAnalytics: true,
runtimeCaching: [
// Cache all main pages permanently
{
urlPattern:
/^https:\/\/nextpgp\.vercel\.app\/($|generate|import|encrypt|decrypt|login|create-vault|vault|cloud-backup|cloud-manage|about|offline)$/,
handler: "NetworkFirst",
options: {
cacheName: "main-pages",
networkTimeoutSeconds: 3,
expiration: {
maxEntries: 13,
maxAgeSeconds: 60 * 60 * 24 * 365,
},
},
},
// Cache static assets (JS, CSS, images, fonts) permanently
{
urlPattern: ({ request }) =>
["style", "script", "worker"].includes(request.destination),
handler: "NetworkFirst",
options: {
cacheName: "static-resources",
expiration: {
maxEntries: 50,
maxAgeSeconds: 60 * 60 * 24 * 365,
},
},
},
{
urlPattern: ({ request }) => request.destination === "image",
handler: "StaleWhileRevalidate",
options: {
cacheName: "image-cache",
expiration: {
maxEntries: 50,
maxAgeSeconds: 60 * 60 * 24 * 365,
},
},
},
],
},
});
const nextConfig = {
turbopack: {
resolveExtensions: [".mdx", ".tsx", ".ts", ".jsx", ".js", ".json"],
},
webpack(config) {
config.plugins.push(
new webpack.DefinePlugin({
__BUILD_TIMESTAMP__: JSON.stringify(buildTimestamp),
})
);
return config;
},
};
module.exports = withPWA(nextConfig);