Skip to content

Commit 41139dd

Browse files
committed
feat: Implement Progressive Web App (PWA) functionality and update branding assets
1 parent 95958af commit 41139dd

34 files changed

Lines changed: 3882 additions & 264 deletions

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,9 @@ yarn-error.log*
4040
# typescript
4141
*.tsbuildinfo
4242
next-env.d.ts
43+
44+
# PWA
45+
public/sw.js
46+
public/sw.js.map
47+
public/workbox-*.js
48+
public/workbox-*.js.map

next-pwa.d.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
declare module 'next-pwa' {
2+
import { NextConfig } from 'next';
3+
4+
interface PWAConfig {
5+
dest?: string;
6+
register?: boolean;
7+
skipWaiting?: boolean;
8+
disable?: boolean;
9+
fallbacks?: {
10+
document?: string;
11+
image?: string;
12+
audio?: string;
13+
video?: string;
14+
font?: string;
15+
};
16+
runtimeCaching?: Array<{
17+
urlPattern: RegExp | string;
18+
handler: 'CacheFirst' | 'NetworkFirst' | 'StaleWhileRevalidate' | 'NetworkOnly' | 'CacheOnly';
19+
options?: {
20+
cacheName?: string;
21+
networkTimeoutSeconds?: number;
22+
expiration?: {
23+
maxEntries?: number;
24+
maxAgeSeconds?: number;
25+
};
26+
};
27+
}>;
28+
}
29+
30+
export default function withPWA(config: PWAConfig): (nextConfig: NextConfig) => NextConfig;
31+
}

next.config.ts

Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,68 @@
11
import type { NextConfig } from "next";
2+
import withPWA from "next-pwa";
23

34
const nextConfig: NextConfig = {
5+
turbopack: {}, // Silence Turbopack warning for webpack-based next-pwa
46
experimental: {
57
serverActions: {
68
bodySizeLimit: '5mb',
79
},
810
},
911
};
1012

11-
export default nextConfig;
13+
export default withPWA({
14+
dest: 'public',
15+
register: true,
16+
skipWaiting: true,
17+
disable: false, // Enable in dev for testing
18+
fallbacks: {
19+
document: '/_offline.html',
20+
},
21+
runtimeCaching: [
22+
{
23+
urlPattern: /^https:\/\/fonts\.(?:gstatic|googleapis)\.com\/.*/i,
24+
handler: 'CacheFirst',
25+
options: {
26+
cacheName: 'google-fonts',
27+
expiration: {
28+
maxEntries: 4,
29+
maxAgeSeconds: 365 * 24 * 60 * 60, // 1 year
30+
},
31+
},
32+
},
33+
{
34+
urlPattern: /^https:\/\/api\.github\.com\/.*/i,
35+
handler: 'NetworkFirst',
36+
options: {
37+
cacheName: 'github-api',
38+
networkTimeoutSeconds: 10,
39+
expiration: {
40+
maxEntries: 50,
41+
maxAgeSeconds: 5 * 60, // 5 minutes
42+
},
43+
},
44+
},
45+
{
46+
urlPattern: /\.(?:png|jpg|jpeg|svg|gif|webp|ico)$/i,
47+
handler: 'CacheFirst',
48+
options: {
49+
cacheName: 'static-images',
50+
expiration: {
51+
maxEntries: 60,
52+
maxAgeSeconds: 30 * 24 * 60 * 60, // 30 days
53+
},
54+
},
55+
},
56+
{
57+
urlPattern: /\.(?:js|css)$/i,
58+
handler: 'StaleWhileRevalidate',
59+
options: {
60+
cacheName: 'static-resources',
61+
expiration: {
62+
maxEntries: 100,
63+
maxAgeSeconds: 24 * 60 * 60, // 24 hours
64+
},
65+
},
66+
},
67+
],
68+
})(nextConfig);

0 commit comments

Comments
 (0)