-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathnext.config.mjs
More file actions
65 lines (62 loc) · 1.51 KB
/
Copy pathnext.config.mjs
File metadata and controls
65 lines (62 loc) · 1.51 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
import withPWAInit from '@ducanh2912/next-pwa';
const withPWA = withPWAInit({
dest: 'public',
disable: process.env.NODE_ENV === 'development',
register: true,
skipWaiting: true,
cacheOnFrontendNav: true,
aggressiveFrontEndNavCaching: true,
fallbacks: {
document: '/offline',
image: '/fallback-image.png'
},
workboxOptions: {
runtimeCaching: [
{
urlPattern: /^https?.*\/api\/.*$/,
handler: 'NetworkFirst',
options: {
cacheName: 'api-cache',
expiration: {
maxEntries: 50,
maxAgeSeconds: 60 * 60 * 24 // 24 hours
},
cacheableResponse: {
statuses: [0, 200]
}
}
},
{
urlPattern: /\.(?:png|jpg|jpeg|svg|gif|webp)$/,
handler: 'CacheFirst',
options: {
cacheName: 'image-cache',
expiration: {
maxEntries: 100,
maxAgeSeconds: 60 * 60 * 24 * 30 // 30 days
}
}
},
{
urlPattern: /\.(?:woff|woff2|ttf|eot)$/,
handler: 'CacheFirst',
options: {
cacheName: 'font-cache',
expiration: {
maxEntries: 50,
maxAgeSeconds: 60 * 60 * 24 * 365 // 1 year
}
}
}
]
}
});
/** @type {import('next').NextConfig} */
const nextConfig = {
// Ensure proper handling of CSS imports
webpack: (config) => {
// Important: return the modified config
return config;
}
};
export default withPWA(nextConfig);