Files
ZDXSGYHT/library/build/pwa/index.ts
liangjian 836c61ac55 @@@@@@
2026-01-27 16:32:15 +08:00

47 lines
1.1 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { VitePWA } from 'vite-plugin-pwa'
export const createPwa = (nodeEnv: string, pwaDev: boolean) => {
return VitePWA({
base: nodeEnv === 'development' && pwaDev ? '/' : './', // ./ 或 /
registerType: 'autoUpdate', // promp弹窗提示手动更新、autoUpdate自动更新建议使用自动更新
workbox: {
cleanupOutdatedCaches: true,
},
devOptions: {
enabled: pwaDev,
},
manifest: {
lang: 'zh',
name: 'school-apartment',
short_name: 'school-apartment',
description: '迪联科技',
background_color: '#ffffff',
theme_color: '#ffffff',
icons: [
{
src: 'pwa-64x64.png',
sizes: '64x64',
type: 'image/png',
},
{
src: 'pwa-192x192.png',
sizes: '192x192',
type: 'image/png',
},
{
src: 'pwa-512x512.png',
sizes: '512x512',
type: 'image/png',
purpose: 'any',
},
{
src: 'maskable-icon-512x512.png',
sizes: '512x512',
type: 'image/png',
purpose: 'maskable',
},
],
},
})
}