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