25

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.

3 Answers 3

48

I resolved this by doing the following:

  1. Removing the registerServiceWorker.js file
  2. removing the import of registerServiceWorker.js from main.js.
  3. removing the PWA plugin from the devDependencies in package.json.
Sign up to request clarification or add additional context in comments.

3 Comments

I found that I also had to remove the manifest.json file, usually located in the /public directory.
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?
and remove register-service-worker in package.json dependencies
15

Vue 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

10

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');
  }
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.