1
0
Fork 0
mirror of https://github.com/betagouv/mon-entreprise synced 2025-02-08 22:15:02 +00:00
mon-entreprise/site/vite-pwa-options.ts
Jérémy Rialland f108a6d7d1 Rework PWA to precache less files
Use network first strategy by default
Show the prompt after 3 days without reload
2022-08-29 09:49:13 +02:00

49 lines
1.1 KiB
TypeScript

import { Options } from 'vite-plugin-pwa'
export const pwaOptions: Partial<Options> = {
// selfDestroying: true, // Unregister PWA
registerType: 'prompt',
strategies: 'injectManifest',
srcDir: 'source',
filename: 'sw.ts',
injectManifest: {
maximumFileSizeToCacheInBytes: 3000000,
manifestTransforms: [
(entries) => {
const manifest = entries.filter(
(entry) =>
!/assets\/.*(-legacy|lazy_)/.test(entry.url) &&
(entry.url.endsWith('.html')
? /(infrance|mon-entreprise)\.html/.test(entry.url)
: true)
)
return { manifest }
},
],
},
includeAssets: ['logo-*.png'],
manifest: {
start_url: '/',
name: 'Mon entreprise',
short_name: 'Mon entreprise',
description: "L'assistant officiel du créateur d'entreprise",
lang: 'fr',
orientation: 'portrait-primary',
display: 'minimal-ui',
theme_color: '#2975d1',
background_color: '#ffffff',
icons: [
{
src: '/favicon/android-chrome-192x192-shadow.png?v=2.0',
sizes: '192x192',
type: 'image/png',
},
{
src: '/favicon/android-chrome-512x512-shadow.png?v=2.0',
sizes: '512x512',
type: 'image/png',
},
],
},
}