-
Notifications
You must be signed in to change notification settings - Fork 0
/
next.config.js
58 lines (56 loc) · 1.32 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
const withPWA = require('@ducanh2912/next-pwa').default({
register: process.env.NODE_ENV !== 'development',
disable: process.env.NODE_ENV === 'development',
dest: 'public',
sw: 'serviceWorker.js',
publicExcludes: ['!wiki/**/*'],
cacheStartUrl: false,
dynamicStartUrl: false,
workboxOptions: {
skipWaiting: false,
additionalManifestEntries: [
{ url: '/offline', revision: null },
],
importScripts: ['/articlesSW.js'],
runtimeCaching: [
{
urlPattern: ({ url: { pathname }, sameOrigin }) => // /manifest.json?locale=...
sameOrigin && (
pathname.startsWith('/manifest.json')
),
handler: 'NetworkFirst',
options: {
cacheName: 'manifest'
}
},
{
urlPattern: ({ url: { pathname }, sameOrigin }) => // static assets, /favicon.ico
sameOrigin && (
pathname.startsWith('/assets/') ||
pathname.startsWith('/favicon.ico')
),
handler: 'StaleWhileRevalidate',
options: {
cacheName: 'static-assets'
}
},
{
urlPattern: /\/.*/i, // everything else
handler: 'NetworkOnly',
options: {
precacheFallback: {
fallbackURL: '/offline',
}
}
}
]
}
});
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
experimental: {
serverActions: true,
}
};
module.exports = withPWA(nextConfig);