vite-pwa / docs

Documentation: PWA integrations for Vite and the ecosystem
https://vite-pwa-org.netlify.app/
MIT License
197 stars 45 forks source link

Vue Documentation #38

Closed feamsr00 closed 1 year ago

feamsr00 commented 1 year ago

Hello!

I'm sorry this is such a simple question.

https://vite-pwa-org.netlify.app/frameworks/vue.html mentions a module type declaration and provides the contents for virtual:pwa-register/vue. What exactly if this file to be named and where is it supposed to live?

It would be awesome if this was also clarified in the docs.

Thanks in advance!

userquin commented 1 year ago

@feamsr00 virtual:pwa-register/vue is a Vite virtual module, use it as any other static import; you should add ts definition via vite-plugin-pwa/client in any d.ts file inside src folder via reference, for example src/vite-env.d.ts:

/// <reference types="vite/client" />
/// <reference types="vite-plugin-pwa/client" />
/// <reference types="vite-plugin-pwa/info" />

or add it inside compilerOptions.types in jsconfig.json or tsconfig.json file:

"compilerOptions": {
  "types": ["vite/client", "vite-plugin-pwa/client", "vite-plugin-pwa/info"]
}

You can check this Vue component: https://github.com/vite-pwa/vite-plugin-pwa/blob/main/examples/vue-router/src/ReloadPrompt.vue#L2

You can also check the ReloadPrompt.vue component on the docs, just open the code, the static import can be found also there.

feamsr00 commented 1 year ago

This this worked much better. Thanks!

May I suggest that this be added to the documentation some how?

userquin commented 1 year ago

@feamsr00 it is there:

imagen