Blame view

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