Skip to content

Commit e591286

Browse files
authored
Merge pull request #33 from openpatch/copilot/add-pwa-functionality
Add PWA support for offline functionality
2 parents b9c650a + cf43310 commit e591286

File tree

6 files changed

+2867
-170
lines changed

6 files changed

+2867
-170
lines changed

platforms/web/index.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
<meta property="og:title" content="Learningmap - Interactive Visual Maps for Teaching and Learning" />
1212
<meta property="og:description" content="Create, share, and explore interactive visual learning maps. Perfect for teachers and students." />
1313
<meta property="og:type" content="website" />
14+
<meta name="theme-color" content="#ffffff" />
15+
<link rel="apple-touch-icon" href="/pwa-192x192.png" />
1416
</head>
1517

1618
<body>

platforms/web/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
"globals": "^16.4.0",
2929
"typescript": "~5.9.3",
3030
"typescript-eslint": "^8.45.0",
31-
"vite": "^7.1.9"
31+
"vite": "^7.1.9",
32+
"vite-plugin-pwa": "^1.1.0",
33+
"workbox-window": "^7.3.0"
3234
}
3335
}
8.75 KB
Loading
29.7 KB
Loading

platforms/web/vite.config.ts

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,61 @@
11
import { defineConfig } from 'vite'
22
import react from '@vitejs/plugin-react'
3+
import { VitePWA } from 'vite-plugin-pwa'
34

45
// https://vite.dev/config/
56
export default defineConfig({
6-
plugins: [react()],
7+
plugins: [
8+
react(),
9+
VitePWA({
10+
registerType: 'autoUpdate',
11+
includeAssets: ['logo.svg', 'concert_one_latin.woff2'],
12+
manifest: {
13+
name: 'Learningmap - Interactive Visual Maps for Teaching and Learning',
14+
short_name: 'Learningmap',
15+
description: 'Create, share, and explore interactive visual learning maps. Perfect for teachers and students. All data stored locally in your browser for privacy and offline access.',
16+
theme_color: '#ffffff',
17+
background_color: '#ffffff',
18+
display: 'standalone',
19+
scope: '/',
20+
start_url: '/',
21+
icons: [
22+
{
23+
src: 'pwa-192x192.png',
24+
sizes: '192x192',
25+
type: 'image/png'
26+
},
27+
{
28+
src: 'pwa-512x512.png',
29+
sizes: '512x512',
30+
type: 'image/png'
31+
},
32+
{
33+
src: 'pwa-512x512.png',
34+
sizes: '512x512',
35+
type: 'image/png',
36+
purpose: 'any maskable'
37+
}
38+
]
39+
},
40+
workbox: {
41+
globPatterns: ['**/*.{js,css,html,svg,png,woff2,json}'],
42+
runtimeCaching: [
43+
{
44+
urlPattern: /^https:\/\/json\.openpatch\.org\/.*/i,
45+
handler: 'NetworkFirst',
46+
options: {
47+
cacheName: 'json-api-cache',
48+
expiration: {
49+
maxEntries: 50,
50+
maxAgeSeconds: 60 * 60 * 24 * 7 // 1 week
51+
},
52+
cacheableResponse: {
53+
statuses: [0, 200]
54+
}
55+
}
56+
}
57+
]
58+
}
59+
})
60+
],
761
})

0 commit comments

Comments
 (0)