workbox-webpack-plugin

How can I customize my Service Worker based on environment variables?

纵然是瞬间 提交于 2019-12-05 05:29:47
Edit: This looks like a duplicate of this Unresolved Question . Do I mark this as answered, or delete? I am using InjectManifest from workbox-webpack-plugin inside a Vue CLI 3 app. The custom service worker that I am injecting into has handling for Firebase Cloud Messaging (FCM). I need to listen for messages from different senders based on my environment (local, staging, and production). Ideally, service-worker.js would look like this: importScripts('https://www.gstatic.com/firebasejs/4.8.1/firebase-app.js'); importScripts('https://www.gstatic.com/firebasejs/4.8.1/firebase-messaging.js');