After adding the
"@vue/cli-plugin-pwa": "^4.5.12"
to my package.json and setting up workbox configuration in my vue.config.js
, I encountered an issue. When running npm run build:prd
with the script vue-cli-service build --mode prod.example
, I noticed that the service-worker.js
file was missing from my dist folder.
This is what my vue.config.js looks like:
module.exports = {
// ...other vue-cli plugin options...
pwa: {
// configure the workbox plugin
workboxPluginMode: 'InjectManifest',
workboxOptions: {
// swSrc is required in InjectManifest mode.
swSrc: 'src/service-worker.js',
// ...other Workbox options...
}
}
}
I attempted moving the PWA plugin configuration into my package.json, but this did not resolve the issue either. The service-worker.js
file still couldn't be found in the dist folder.
To temporarily address this problem, I resorted to placing the service-worker.js
in my public
folder. However, this caused another problem as the service worker wouldn't update automatically with each new release. My goal is to notify the client when a new version is available, but because the service-worker.js
remains static, I am unable to trigger the update
event.