forked from SoroLabs/SoroTask
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnext.config.ts
More file actions
59 lines (56 loc) · 1.55 KB
/
Copy pathnext.config.ts
File metadata and controls
59 lines (56 loc) · 1.55 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
import type { NextConfig } from 'next';
import withPWAInit from '@ducanh2912/next-pwa';
const withPWA = withPWAInit({
dest: 'public',
disable: process.env.NODE_NODE_ENV === 'development',
register: true,
skipWaiting: true,
workboxOptions: {
runtimeCaching: [
{
// Cache Google Fonts / Web Fonts
urlPattern: /^https:\/\/fonts\.(?:googleapis|gstatic)\.com\/.*/i,
handler: 'CacheFirst',
options: {
cacheName: 'google-fonts',
expiration: {
maxEntries: 10,
maxAgeSeconds: 365 * 24 * 60 * 60, // 1 year
},
},
},
{
// Cache Static Assets (Images, Icons, Fonts)
urlPattern: /\.(?:png|jpg|jpeg|svg|gif|webp|ico|woff|woff2)$/i,
handler: 'StaleWhileRevalidate',
options: {
cacheName: 'static-assets',
expiration: {
maxEntries: 60,
maxAgeSeconds: 30 * 24 * 60 * 60, // 30 days
},
},
},
{
// Cache Read-Only API Task Queries for Offline Reading
urlPattern: /\/api\/v1\/(?:tasks|history).*/i,
handler: 'NetworkFirst',
options: {
cacheName: 'api-read-cache',
networkTimeoutSeconds: 5,
expiration: {
maxEntries: 50,
maxAgeSeconds: 24 * 60 * 60, // 24 hours
},
cacheableResponse: {
statuses: [0, 200],
},
},
},
],
},
});
const nextConfig: NextConfig = {
reactStrictMode: true,
};
export default withPWA(nextConfig);