2020-12-13 21:17:37 +08:00
|
|
|
import { VitePWA } from 'vite-plugin-pwa';
|
2021-01-09 23:28:52 +08:00
|
|
|
|
2020-12-22 22:13:03 +08:00
|
|
|
import { ViteEnv } from '../../utils';
|
2020-12-13 21:17:37 +08:00
|
|
|
|
2021-01-09 23:28:52 +08:00
|
|
|
export function configPwaConfig(env: ViteEnv, isBulid: boolean) {
|
|
|
|
const { VITE_USE_PWA, VITE_GLOB_APP_TITLE, VITE_GLOB_APP_SHORT_NAME } = env;
|
2020-12-13 21:17:37 +08:00
|
|
|
|
2021-01-09 23:28:52 +08:00
|
|
|
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;
|
2020-12-13 21:17:37 +08:00
|
|
|
}
|
2021-01-09 23:28:52 +08:00
|
|
|
return [];
|
2020-12-13 21:17:37 +08:00
|
|
|
}
|