title: Cannot Register Custom Firebase FCM Service Worker With Webpack
body: <p>Users can install our software anywhere, and we can’t guarantee a file will exist in the root of the domain. To solve this I register a custom service worker for FCM and everything works. No issues.</p>
  <p>BUT! This only works on the local dev machine. On the production server webpack bundles everything to /dist/ and it cannot find the file to register the service worker.</p>
  <p>So I am curious how to make the following code work with webpack.</p>
  <p>Specifically:</p>
  <pre><code>navigator.serviceWorker.register('/public/js/services/firebase-messaging-sw.js') 
  </code></pre>
  <p>The above does not work with webpack as on the server it points to a non-existing file. The full process minus some code below.</p>
  <pre><code>    navigator.serviceWorker.register('/public/js/services/firebase-messaging-sw.js')
              .then((registration) =&gt; {
                  this.messaging.getToken({serviceWorkerRegistration: registration, vapidKey: &quot;CODE_HERE&quot;}).then((currentToken) =&gt; {
                      //just some code here, removed to keep example smaller
                      }
                  }).catch((err) =&gt; {
                      //just some code here, removed to keep example smaller
                  });
              });
  </code></pre>