laravel / vite-plugin

Laravel plugin for Vite.
MIT License
805 stars 152 forks source link

Laravel vite with vite-pwa-plugin #193

Closed LCD344 closed 1 year ago

LCD344 commented 1 year ago

Description:

I just finished converting a PWA from laravel mix to the vite plugin - everything was pretty straightforward, but the pwa isn't caching for offline use.

you can see the vite setup here https://github.com/el-coop/app/blob/master/vite.config.js the reason I'm making it build into the public directory and not into the build directory is because the pwa plugin doesn't include the "build" prefix in the cache manifest (so it shows: re([{"revision":null,"url":"assets/_commonjsHelpers-edff4021.js"},{"revision":null,"url":"assets/_plugin-vue_export-helper-9d2f2293.js"},

anyway, now the service worker works, but it never caches for offline use - I recently updated a different app similarly (but non-laravel app) and there the caching works...

Steps To Reproduce:

Create a laravel/vue app and copy the next files

viteconfig: https://github.com/el-coop/app/blob/master/vite.config.js serviceWorker: https://github.com/el-coop/app/blob/master/resources/js/serviceWorker/serviceWorker.js registerServiceWorker: https://github.com/el-coop/app/blob/master/resources/js/serviceWorker/registerServiceWorker.js view: https://github.com/el-coop/app/blob/master/resources/views/layouts/plain.blade.php

make some entry point for the app and include the registerServiceWorker file in it You will see there is no "Content has been cached for offline use." console log - and no way to load the app when offline... Also you can see this console log doesnt appear on the following url app.elcoop.io

thanks!

EDIT never mind - got it working. its been a long day haha

SergkeiM commented 1 year ago

@LCD344 what was the solution for the issue?

LCD344 commented 1 year ago

@LCD344 what was the solution for the issue?

I disabled the build folder - you can see in the files I linked - specifically in thee vite.config.js - for a working version.

SergkeiM commented 1 year ago

@LCD344 what was the solution for the issue?

I disabled the build folder - you can see in the files I linked - specifically in thee vite.config.js - for a working version.

Thanks