pwa.ts 833 B

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