Overriding precacheConfig in service-worker.js
-
I am building a pwa app and after the build is complete I am moving everything from the dist/pwa-mat folder to a different to run my app. However I am getting errors because the precacheConfig is configured to look at the dist/pwa-mat for all the files, but it is not finding the files because I am not using the same file structure I am just copying over everything from the dist/pwa-mat folder to the folder where I am running my app from. Is there a way I can override this and point it somewhere else?
I already have the publicPath set up in the quasar.conf.js file to the file path where I want my app to run from. Here is an example.
.
However setting up the public path does not seem to make a difference when it come to overriding the precacheConfig.
-
@rstoenescu I think this may be a bug with the quasar cli and the sw-precache-webpack-plugin. I have a similar problem and started tracing through the quasar source code and found.
line of 401 of https://github.com/quasarframework/quasar-cli/blob/0eab359c1741f6d6304fcd5359b592c628b35128/lib/build/webpack-config.js
we can see that
stripPrefix: cfg.build.distDir + ‘/’in theory the stripPrefix should remove the ‘dist/pwa-mat’, so it doesn’t end up in the service worker, but it doesn’t
I tried adding my own stripPrefix property to the ‘quasar.conf.js’, but obviosly that won’t help, because the q-cli is hard coding the stripPrefix based of the cfg.build.distDir
the docs state that the distDir should default to ‘Relative path to project root directory. Default is ‘dist/{ctx.modeName}-{ctx.themeName}’. Applies to all Modes except for Cordova.’ http://quasar-framework.org/guide/app-quasar.conf.js.html
line 225 of this file seems to prove this https://github.com/quasarframework/quasar-cli/blob/16df4efe6555e1a8c64c05357468bb72d57411c4/lib/quasar-config.js
HOWEVER the stripPrefix doesn’t seem to be working with the quasar defaults.
If I manually add ‘distDir: ‘dist/pwa-mat’’ to the build in quasar-config.js everything seems to work as expected.
I my case, i don’t really want to manually add the distDir to my config, because we are building for a couple different environments.