I have a functioning Bootstrap app which uses a Service Worker for background processing and I'm now rewriting this app as a Quasar SPA. Everything is pretty much working, but I can't figure out how to wrangle Quasar/Webpack to provide the Service Worker file. Note that I'm trying to create an SPA and not a PWA.
I think the problem is that I need to tell Quasar/Webpack to provide an unmangled version of the service worker file and name.
So assume my service worker is:
// src/modules/sw.js
import * as moment from "moment";
console.log(`From worker: worker started at ${moment().format("HH:mm:ss")}`);
...
and I'm trying to load this service worker:
// src/modules/foo.js
let worker = new Worker("/modules/sw.js");
results in the error:
Failed to load resource: the server responded with a status of 404 (Not Found) https://localhost:44444/modules/sw.js
and indeed, there is no sw.js
anywhere in dist if I run quasar build
.
In the spirit of 10 million monkeys with typewriters trying to write a Shakespeare play I tried adding an entry to quasar.conf.js
, but this had no beneficial effect:
sourceFiles: {
serviceWorker: 'src/modules/sw.js'
}