mattbartel
4 days ago

SPA/PWA on Laravel Vapor

Posted 4 days ago by mattbartel

I'm working on a Laravel/Vue-powered Progressive Web App and hope to deploy it in Vapor. I've run into some issues with the way assets are handled in Vapor and wondered if anyone could offer suggestions.

My JavaScript/CSS assets are being built in Laravel Mix. As long as I use the correct asset() helper in my blade templates, plus extract my Vue styles into a separate file ("extractVueStyles = true" in Mix), the assets are correctly uploaded to the CDN and my code references are correctly updated.

My PWA service-provider is being built using the workbox-webpack-plugin. The last issue I'm having is how to serve the service-provider.js. My understanding is that service providers must be served from the same origin as the referrer or the browser will not register them, so the Vapor CDN doesn't work.

My only thought right now is to set up a laravel route that serves up the static service-provider.js file on the same domain, but obviously having the PHP overhead just to serve a static file is a little annoying.

Any ideas?

Please sign in or create an account to participate in this conversation.