Vite PWA Plugin does not register the service worker and gives me a 404 error status

3.2k Views Asked by At

I'm trying to make a PWA application with the vite plugin and I don't know what I'm doing wrong but as far as I understand it, the app does not register the service worker and also not caching anything (on the dev tools the cache storage menu is empty).

I'm new at this, so any help will be much appreciated

I'm using react and I'm registering the service worker in the main.js file like this

import { registerSW } from 'virtual:pwa-register'

ReactDOM.createRoot(document.getElementById('root')).render(
    <React Code/>
)

if ("serviceWorker" in navigator) {
    registerSW()
}

I'm posting my vite.config.js

vite.config.js

dev tools

error

0

There are 0 best solutions below