pwa.ts 777 B

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