feat: add service worker for PWA support (offline caching, installability)
- Add sw.js with stale-while-revalidate caching for static assets - Network-first for HTML navigation, skip API/WS requests - Register service worker in main.tsx on page load - Enhanced manifest.json with orientation, categories, and all icon sizes - App is now installable as a standalone PWA on mobile and desktop
This commit is contained in:
@@ -5,6 +5,15 @@ import { ErrorBoundary } from './components/ErrorBoundary'
|
||||
import { ThemeProvider } from './contexts/ThemeContext'
|
||||
import './index.css'
|
||||
|
||||
// Register service worker for PWA support (offline caching, installability)
|
||||
if ('serviceWorker' in navigator) {
|
||||
window.addEventListener('load', () => {
|
||||
navigator.serviceWorker.register('/sw.js').catch(() => {
|
||||
// SW registration failed — app works fine without it
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
ReactDOM.createRoot(document.getElementById('root')!).render(
|
||||
<React.StrictMode>
|
||||
<ErrorBoundary>
|
||||
|
||||
Reference in New Issue
Block a user