vite-pwa / vite-plugin-pwa

Zero-config PWA for Vite
https://vite-pwa-org.netlify.app/
MIT License
3.1k stars 204 forks source link

How to separate output path for `sw.js` and `workbox-********.js` #467

Open mmn6d6d6e opened 1 year ago

mmn6d6d6e commented 1 year ago

I'm using laravel 9 The index.html is seved at /public while the transpiled js files are at /public/build By Laravel 9 Vite default setting the outDir is at public/build and will always be cleaned when vite build is executed

If i left outDir by default:

If i change the outDir to public:

The ideal scenario I had in my mind:

Is it possible? or is there alternative way with both no max scope allowed error neither piling up workbox-********.js files?

vheins commented 1 year ago

yeah any idea for this?

userquin commented 1 year ago

@mmn6d6d6e @vheins

The problem with PWA is about the scope and the location of the service worker and web manifest assets. Since vite-laravel-plugin is hacking Vite to write all assets in public/build folder we cannot hack Vite.

You have 2 solutions: 1) add custom http header