vite-pwa / vite-plugin-pwa

Zero-config PWA for Vite

Home Page:https://vite-pwa-org.netlify.app/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

self.__WB_MANIFEST is undefined when the strategies is 'injectManifest'

eRendon opened this issue · comments

Hi!,
I have a problem when deploy the proyecto to vercel or any host and previw server in local.

Versión PWA plugin vite

"vite-plugin-pwa": "^0.11.13",

Versión vite
"vite": "^2.6.7",

Version vue
"vue": "^3.0.5",

The configuration of mi custom sw
image

the configuration of vite plugin
image

When build the proyect, the error is
image

and inspec the vendor, i see
image

and in the self instance, not see __WB_MANIFEST
image

and the structure of my proyect
image

i don´t know why not inyected the manifest context in the window context...

Thanks for your help

@eRendon try to upgrade vue version to 3.2, if you cannot upgrade the vue version try adding this line at the top of your sw.ts file:

/// <reference lib="webworker" />

@userquin now my dependences are
image

i upgrade vue version. Builded whit sourcemap, i see the problem in the PrecachingControll.js file
image

and the error
image

add to the /// <reference lib="webworker"/> from the sw file

image

@eRendon what are you doing importing the src/sw.ts from your src/main.ts module? you cannot import the sw on the main entry, you should remove that import from that module, registerSW call will register the sw.

I test your repo (https://github.com/eRendon/vite-vue3-tailwind) using pnpm instead npm and it is working on my local, you will need:

  • remove workbox-precaching from dependencies and add it as dev dependency
  • add workbox-window as dev dependency
  • remove import './sw'; from your main.ts (line 21)

imagen

@userquin

Thanks!!!!! maybe the problem are the workbox-window as dev dependencie and other libraries that i have in dependencies.
The sw importe in the main, is to practice whit the update component registration and notification.

Thanks so much. The problem is solved.