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

Where should I place sw.js file in custom serviceWorker workbox injectManifest

jetro4u opened this issue · comments

I have conflicting idea on which directory to place the sw.js file.

According to the documentation here https://vite-plugin-pwa.netlify.app/guide/inject-manifest.html#custom-service-worker under Runtime, custom service worker is supposed to be placed in public/sw.js

But in the documentation under workbox the setting below placed it in the src folder

VitePWA({
  strategies: 'injectManifest',
  srcDir: 'src',
  filename: 'sw.ts'
})

When I placed it outside of the public folder I used to get the error that it can't be compiled