vite-pwa / vitepress

Zero-config PWA Plugin for VitePress
https://vite-pwa-org.netlify.app/frameworks/vitepress
MIT License
36 stars 2 forks source link

Pending #2

Closed userquin closed 1 year ago

userquin commented 1 year ago

We need:

userquin commented 1 year ago

@brc-dd the problem is the following:

The VitePress head configuration is static (IIRC), the PWA may need to inject the webmanifest link and the registerSW.js or the same code but inlined (register the service worker in the browser).

In dev, there is no need to inject anything (pwa dev options will be disabled or throw error: I will check if we can use it to test the webmanifest).

So, we need to check if we're running dev server or building the app, but we also need to do a few more things, since the pwa plugin will do a lot of automatic work, depending on the user configuration and the usage: for example, the pwa plugin exposes a set of virtual modules to integrate with the client allowing interacting, such as prompt dialog before updating the app once detected a new version.

If the user is importing any of the virtual modules exposed by the pwa plugin, then, there is no need to inject the registerSW.js or its inlined version, but will require to inject the header link.

If you run the dev server in the example, there will be a few errors, since the webmanifest and registerSW.js will not be generated.

userquin commented 1 year ago

I need to test it importing virtual from pwa on the pwa-prompt example!

closed via https://github.com/userquin/vite-pwa-vitepress-integration/commit/303b00364706a7f1d9867f8071fbc96f173f6402