I'm having some issues with caching my files using the default service worker that comes with VueCLI 3. I would prefer to just use the default browser caching mechanism, but can't seem to disable the PWA plugin as its not in the vue.config.js file. Passing a blank object to the pwa option doesn't work either as the object is merged and not overwritten.
Add a comment
|
3 Answers
I resolved this by doing the following:
- Removing the
registerServiceWorker.jsfile - removing the import of
registerServiceWorker.jsfrommain.js. - removing the
PWAplugin from thedevDependenciesinpackage.json.
3 Comments
Chase
I found that I also had to remove the
manifest.json file, usually located in the /public directory.Lulu Cheng
Hello, after following this three step, the service worker cache just won't go away, any hint on how to blow that away on the client side?
Evol Rof
and remove
register-service-worker in package.json dependenciesVue enabled a method to disable pwa for certain builds in version 4. Now you can add --skip-plugins pluginname during your build. This one worked for me just fine:
npx vue-cli-service build --skip-plugins pwa,workbox
Ref: https://cli.vuejs.org/guide/cli-service.html#skipping-plugins
Comments
There is an open but accepted proposal to add this to the core functionality: https://github.com/vuejs/vue-cli/issues/3830
EDIT:
Via command line: https://cli.vuejs.org/guide/cli-service.html#skipping-plugins
npx vue-cli-service build --skip-plugins pwa,workbox
Via vue.config.js:
module.exports = {
chainWebpack: config => {
config.plugins.delete('pwa');
config.plugins.delete('workbox');
}
}