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