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:
- the
workbox-********.js is generated on /public/build, good. It'll automatically cleaned on each build
- the
sw.js is also generated on /public/build, not good. This is causing error The path of the provided scope ('/public') is not under the max scope allowed ('/public/build/'). Adjust the scope, move the Service Worker script, or use the Service-Worker-Allowed HTTP header to allow the scope. and I'd rather not change web service settings to set Service-Worker-Allowed HTTP header
If i change the outDir to public:
- the
sw.js is generated on /public, good. No max scope error.
- the
workbox-********.js is also generated on /public, not good. the old one need to be manually cleaned if newer one have different hash, or need additional plugin to clean it each build
The ideal scenario I had in my mind:
- generate
workbox-********.js to /public/build so it will be cleaned on each vite build with Laravel 9 default setting
- generate
sw.js to /public and it load /public/build/workbox-********.js
Is it possible? or is there alternative way with both no max scope allowed error neither piling up workbox-********.js files?
I'm using laravel 9
The
index.htmlis seved at/publicwhile the transpiled js files are at/public/buildBy Laravel 9 Vite default setting the outDir is at
public/buildand will always be cleaned whenvite buildis executedIf i left
outDirby default:workbox-********.jsis generated on/public/build, good. It'll automatically cleaned on each buildsw.jsis also generated on/public/build, not good. This is causing errorThe path of the provided scope ('/public') is not under the max scope allowed ('/public/build/'). Adjust the scope, move the Service Worker script, or use the Service-Worker-Allowed HTTP header to allow the scope.and I'd rather not change web service settings to setService-Worker-Allowed HTTPheaderIf i change the
outDirtopublic:sw.jsis generated on/public, good. No max scope error.workbox-********.jsis also generated on/public, not good. the old one need to be manually cleaned if newer one have different hash, or need additional plugin to clean it each buildThe ideal scenario I had in my mind:
workbox-********.jsto/public/buildso it will be cleaned on eachvite buildwith Laravel 9 default settingsw.jsto/publicand it load/public/build/workbox-********.jsIs it possible? or is there alternative way with both no max scope allowed error neither piling up
workbox-********.jsfiles?