Skip to content

Commit 33db7f9

Browse files
committed
change next-pwa in favour of serwist or build will never work, same as jotty/cronmaster
1 parent 2fc7c33 commit 33db7f9

5 files changed

Lines changed: 228 additions & 1833 deletions

File tree

app/sw.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import type { PrecacheEntry, SerwistGlobalConfig } from "serwist";
2+
import { Serwist } from "serwist";
3+
import { defaultCache } from "@serwist/next/worker";
4+
5+
declare global {
6+
interface ServiceWorkerGlobalScope extends SerwistGlobalConfig {
7+
__SW_MANIFEST: (PrecacheEntry | string)[] | undefined;
8+
}
9+
}
10+
11+
declare const self: ServiceWorkerGlobalScope;
12+
13+
const serwist = new Serwist({
14+
precacheEntries: self.__SW_MANIFEST,
15+
skipWaiting: true,
16+
clientsClaim: true,
17+
navigationPreload: true,
18+
runtimeCaching: defaultCache,
19+
});
20+
21+
serwist.addEventListeners();

next.config.mjs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import withPWA from 'next-pwa';
1+
import withSerwist from '@serwist/next';
22

33
/** @type {import('next').NextConfig} */
44
const nextConfig = {
@@ -65,9 +65,8 @@ const nextConfig = {
6565
},
6666
}
6767

68-
export default withPWA({
69-
dest: 'public',
68+
export default withSerwist({
69+
swSrc: 'app/sw.ts',
70+
swDest: 'public/sw.js',
7071
disable: process.env.NODE_ENV === 'development',
71-
register: true,
72-
skipWaiting: true,
7372
})(nextConfig);

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@
2929
"lang-detector": "^1.0.6",
3030
"lottie-react": "^2.4.1",
3131
"next": "^15.5.15",
32-
"next-pwa": "^5.6.0",
32+
"@serwist/next": "^9.0.0",
33+
"serwist": "^9.0.0",
3334
"openpgp": "^6.2.2",
3435
"papaparse": "^5.5.3",
3536
"parse-torrent": "^11.0.19",

tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
"lib": [
44
"dom",
55
"dom.iterable",
6-
"esnext"
6+
"esnext",
7+
"webworker"
78
],
89
"allowJs": true,
910
"skipLibCheck": true,

0 commit comments

Comments
 (0)