Skip to content

Commit 69ed8ea

Browse files
committed
chore: updated pwa plugin, webmanifest exposed as new object
1 parent 983ef6a commit 69ed8ea

File tree

3 files changed

+106
-55
lines changed

3 files changed

+106
-55
lines changed

pnpm-lock.yaml

Lines changed: 97 additions & 53 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/index.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,15 @@ export function defineConfig(config: VitePressPWAOptions<DefaultTheme.Config>) {
5353

5454
vitePressConfig.transformHead = async (ctx) => {
5555
const head = (await userTransformHead?.(ctx)) ?? []
56-
const href = api?.webManifestUrl
57-
href && head.push(['link', { rel: 'manifest', href }])
56+
57+
const webManifestData = api?.webManifestData()
58+
if (webManifestData) {
59+
const href = webManifestData.href
60+
if (webManifestData.useCredentials)
61+
head.push(['link', { rel: 'manifest', href, crossorigin: 'use-credentials' }])
62+
else
63+
head.push(['link', { rel: 'manifest', href }])
64+
}
5865

5966
const registerSWData = api?.registerSWData()
6067
if (registerSWData) {

vite-plugin-pwa-0.12.7.tgz

76 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)