pwa.ts 789 B

12345678910111213141516171819202122232425262728293031323334
  1. /**
  2. * Zero-config PWA for Vite
  3. * https://github.com/antfu/vite-plugin-pwa
  4. */
  5. import { VitePWA } from 'vite-plugin-pwa';
  6. export function configPwaConfig(env: ViteEnv) {
  7. const { VITE_USE_PWA, VITE_GLOB_APP_TITLE, VITE_GLOB_APP_SHORT_NAME } = env;
  8. if (VITE_USE_PWA) {
  9. // vite-plugin-pwa
  10. const pwaPlugin = VitePWA({
  11. manifest: {
  12. name: VITE_GLOB_APP_TITLE,
  13. short_name: VITE_GLOB_APP_SHORT_NAME,
  14. icons: [
  15. {
  16. src: './resource/img/pwa-192x192.png',
  17. sizes: '192x192',
  18. type: 'image/png',
  19. },
  20. {
  21. src: './resource/img/pwa-512x512.png',
  22. sizes: '512x512',
  23. type: 'image/png',
  24. },
  25. ],
  26. },
  27. });
  28. return pwaPlugin;
  29. }
  30. return [];
  31. }