Progress Web Apps (PWA's)
Installation
npm install -D vite-plugin-pwaVite Configuration
// vite.config.ts
import { defineConfig } from 'vite';
import { VitePWA } from 'vite-plugin-pwa';
import aurelia from '@aurelia/vite-plugin';
export default defineConfig({
plugins: [
aurelia(),
VitePWA({
registerType: 'autoUpdate',
workbox: {
globPatterns: ['**/*.{js,css,html,ico,png,svg,woff2}'],
runtimeCaching: [
{
urlPattern: /^https:\/\/api\.yourapp\.com\/.*/i,
handler: 'NetworkFirst',
options: {
cacheName: 'api-cache',
networkTimeoutSeconds: 10,
cacheableResponse: {
statuses: [0, 200]
}
}
}
]
},
manifest: {
name: 'Aurelia PWA',
short_name: 'AureliaPWA',
description: 'My Aurelia Progressive Web App',
theme_color: '#ffffff',
background_color: '#ffffff',
display: 'standalone',
start_url: '/',
icons: [
{
src: '/icons/pwa-192x192.png',
sizes: '192x192',
type: 'image/png',
purpose: 'any'
},
{
src: '/icons/pwa-512x512.png',
sizes: '512x512',
type: 'image/png',
purpose: 'any'
},
{
src: '/icons/pwa-512x512.png',
sizes: '512x512',
type: 'image/png',
purpose: 'maskable'
}
]
}
})
]
});Service Worker Integration
Update Component
Icon Setup
Maskable Icons
Development and Testing
Development Mode
Testing Your PWA
Advanced Caching Strategies
Best Practices
Last updated
Was this helpful?