Skip to content

Commit b8f5ea2

Browse files
authored
445 fix pwa integration (#458)
* Replace next-pwa with serwist in deps * Setup serwist in code
1 parent 4f3db8b commit b8f5ea2

File tree

4 files changed

+374
-2918
lines changed

4 files changed

+374
-2918
lines changed

next.config.js

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { PHASE_DEVELOPMENT_SERVER, PHASE_PRODUCTION_BUILD } from 'next/constants.js';
22
import i18nConfig from './next-i18next.config.js';
3+
import withSerwistInit from '@serwist/next';
34

45
/**
56
* Run `build` or `dev` with `SKIP_ENV_VALIDATION` to skip env validation. This is especially useful
@@ -31,18 +32,10 @@ const nextConfig = {
3132
},
3233
};
3334

34-
// @ts-expect-error We don't need to type this function
35-
const nextConfigFunction = async (phase) => {
36-
if (phase === PHASE_DEVELOPMENT_SERVER || phase === PHASE_PRODUCTION_BUILD) {
37-
const withPWA = (await import('@ducanh2912/next-pwa')).default({
38-
dest: 'public',
39-
disable: 'development' === process.env.NODE_ENV,
40-
// @ts-expect-error buildExcludes is supported at runtime even if missing in types
41-
buildExcludes: [/_next\/dynamic-css-manifest\.json$/],
42-
});
43-
return withPWA(nextConfig);
44-
}
45-
return nextConfig;
46-
};
35+
const withSerwist = withSerwistInit({
36+
swSrc: 'worker/index.ts',
37+
swDest: 'public/sw.js',
38+
disable: process.env.NODE_ENV === 'development', // Incompatible with Turbopack https://github.com/serwist/serwist/issues/54
39+
});
4740

48-
export default nextConfigFunction;
41+
export default withSerwist(nextConfig);

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@
2828
"dependencies": {
2929
"@aws-sdk/client-s3": "^3.515.0",
3030
"@aws-sdk/s3-request-presigner": "^3.515.0",
31-
"@ducanh2912/next-pwa": "^10.2.9",
3231
"@heroicons/react": "^2.1.1",
3332
"@hookform/resolvers": "^3.3.4",
3433
"@icons-pack/react-simple-icons": "^13.7.0",
3534
"@next-auth/prisma-adapter": "^1.0.7",
3635
"@prisma/client": "^6.8.2",
36+
"@serwist/next": "^9.2.1",
3737
"@t3-oss/env-nextjs": "^0.11.1",
3838
"@tanstack/react-query": "^5.79.2",
3939
"@trpc/client": "^11.2.0",
@@ -87,6 +87,7 @@
8787
"prettier": "^3.2.4",
8888
"prettier-plugin-tailwindcss": "^0.6.12",
8989
"prisma": "^6.8.2",
90+
"serwist": "^9.2.1",
9091
"tailwind-merge": "^2.2.0",
9192
"tailwindcss": "^4.1.10",
9293
"ts-node": "^10.9.2",

0 commit comments

Comments
 (0)