index.ts 997 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import { VitePWA, VitePWAOptions } from 'vite-plugin-pwa'
  2. const pwaOptions: Partial<VitePWAOptions> = {
  3. base: './',
  4. registerType: 'autoUpdate', // prompt、autoUpdate
  5. workbox: {
  6. cleanupOutdatedCaches: true,
  7. },
  8. manifest: {
  9. lang: 'zh',
  10. name: 'Vue Shop Vite',
  11. short_name: 'Vue Shop Vite',
  12. description: 'Vue Shop Vite官网、文档、演示地址',
  13. background_color: '#ffffff',
  14. theme_color: '#ffffff',
  15. icons: [
  16. {
  17. src: 'pwa-64x64.png',
  18. sizes: '64x64',
  19. type: 'image/png',
  20. },
  21. {
  22. src: 'pwa-192x192.png',
  23. sizes: '192x192',
  24. type: 'image/png',
  25. },
  26. {
  27. src: 'pwa-512x512.png',
  28. sizes: '512x512',
  29. type: 'image/png',
  30. purpose: 'any',
  31. },
  32. {
  33. src: 'maskable-icon-512x512.png',
  34. sizes: '512x512',
  35. type: 'image/png',
  36. purpose: 'maskable',
  37. },
  38. ],
  39. },
  40. }
  41. export const createPwa = () => {
  42. return VitePWA(pwaOptions)
  43. }