mirror of
https://gitee.com/element-plus/element-plus.git
synced 2024-12-05 20:58:22 +08:00
16 lines
428 B
TypeScript
16 lines
428 B
TypeScript
|
import { resolveConfig } from 'vite'
|
||
|
import type { VitePluginPWAAPI } from 'vite-plugin-pwa'
|
||
|
|
||
|
const rebuildPwa = async () => {
|
||
|
const config = await resolveConfig({}, 'build', 'production')
|
||
|
const pwaPlugin: VitePluginPWAAPI = config.plugins.find((i) => {
|
||
|
return i.name === 'vite-plugin-pwa'
|
||
|
})?.api
|
||
|
|
||
|
if (pwaPlugin && pwaPlugin.generateSW && !pwaPlugin.disabled) {
|
||
|
await pwaPlugin.generateSW()
|
||
|
}
|
||
|
}
|
||
|
|
||
|
rebuildPwa()
|