Blame view

build/vite/plugin/pwa.ts 833 Bytes
vben authored
1
2
3
4
/**
 * Zero-config PWA for Vite
 * https://github.com/antfu/vite-plugin-pwa
 */
Vben authored
5
import type { ViteEnv } from '../../utils';
vben authored
6
7
import { VitePWA } from 'vite-plugin-pwa';
vben authored
8
9
export function configPwaConfig(env: ViteEnv) {
vben authored
10
  const { VITE_USE_PWA, VITE_GLOB_APP_TITLE, VITE_GLOB_APP_SHORT_NAME } = env;
11
12
  if (VITE_USE_PWA) {
vben authored
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
    // 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;
33
  }
vben authored
34
  return [];
35
}