Skip to content

Commit

Permalink
Merge pull request #425 from needim/pwa-dependency-fix
Browse files Browse the repository at this point in the history
PWA missing deps & offline mode fix
  • Loading branch information
steida authored Jun 1, 2024
2 parents df27a51 + d0168b0 commit 2aec5bf
Show file tree
Hide file tree
Showing 6 changed files with 92 additions and 3 deletions.
1 change: 0 additions & 1 deletion .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ jobs:
name: Install pnpm
id: pnpm-install
with:
version: 9
run_install: false

- name: Get pnpm store directory
Expand Down
2 changes: 2 additions & 0 deletions examples/vite-react-pwa/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# React + TypeScript + Vite

DEMO: <https://evolu-vite-react-pwa.vercel.app/>

This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.

Currently, two official plugins are available:
Expand Down
22 changes: 22 additions & 0 deletions examples/vite-react-pwa/netlify.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# [build]
# publish = "dist"
# command = "pnpm run build"

[[redirects]]
from = "/*"
to = "/index.html"
status = 200

[[headers]]
for = "/manifest.webmanifest"
[headers.values]
Content-Type = "application/manifest+json"

[[headers]]
for = "/assets/*"
[headers.values]
cache-control = '''
public,
max-age=0,
must-revalidate
'''
5 changes: 4 additions & 1 deletion examples/vite-react-pwa/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,12 @@
"preview": "vite preview"
},
"dependencies": {
"@effect/schema": "^0.67.16",
"@evolu/react": "^8.0.2",
"effect": "^3.2.7",
"react": "^18.3.1",
"react-dom": "^18.3.1"
"react-dom": "^18.3.1",
"workbox-window": "^7.1.0"
},
"devDependencies": {
"@types/react": "^18.3.1",
Expand Down
63 changes: 63 additions & 0 deletions examples/vite-react-pwa/vercel.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
{
"headers": [
{
"source": "/(.*).(html|js|css|wasm)",
"headers": [
{
"key": "Cache-Control",
"value": "public, max-age=0, must-revalidate"
}
]
},
{
"source": "/sw.js",
"headers": [
{
"key": "Cache-Control",
"value": "public, max-age=0, must-revalidate"
}
]
},
{
"source": "/manifest.webmanifest",
"headers": [
{
"key": "Content-Type",
"value": "application/manifest+json"
}
]
},
{
"source": "/assets/(.*)",
"headers": [
{
"key": "Cache-Control",
"value": "public, max-age=0, must-revalidate"
}
]
},
{
"source": "/(.*)",
"headers": [
{
"key": "X-Content-Type-Options",
"value": "nosniff"
},
{
"key": "X-Frame-Options",
"value": "DENY"
},
{
"key": "X-XSS-Protection",
"value": "1; mode=block"
}
]
}
],
"rewrites": [
{
"source": "/(.*)",
"destination": "/index.html"
}
]
}
2 changes: 1 addition & 1 deletion examples/vite-react-pwa/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export default defineConfig({
},

workbox: {
globPatterns: ["**/*.{js,css,html,svg,png,ico}"],
globPatterns: ["**/*.{js,css,html,svg,png,ico,wasm}"],
cleanupOutdatedCaches: true,
clientsClaim: true,
},
Expand Down

0 comments on commit 2aec5bf

Please sign in to comment.