-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Workbox release v5.0 #5119
Comments
This is likely only possible in a Vue CLI major release since this is a new major as well. You can however upgrade workbox yourself and see if it works for you, i.e. by using yarn's https://legacy.yarnpkg.com/en/docs/selective-version-resolutions/ |
I got v5 to work by replacing @vue/cli-plugin-pwa with workbox-webpack-plugin, using the following vue.config.js: const { InjectManifest } = require('workbox-webpack-plugin')
//optional, but InjectManifest didn't respect the {mode: 'development'} config
process.env.NODE_ENV = 'development'
// vue.config.js
module.exports = {
configureWebpack: {
plugins: [
new InjectManifest({
swSrc: './src/service-worker.js'
})
]
}
} |
This is pretty important to using InjectManifest with typescript: GoogleChrome/workbox#1513 (comment) |
I have the problem that I have to serve my app in our intranet, I found out that finally Workbox 5+ is able to do that: importScripts('/workbox/workbox-v5.1.3/workbox-sw.js');
workbox.setConfig({
modulePathPrefix: '/workbox/workbox-v5.1.3/'
});
workbox.loadModule('workbox-core');
workbox.loadModule('workbox-routing');
workbox.loadModule('workbox-strategies');
workbox.loadModule('workbox-precaching');
if (workbox) {
console.log(` Yay! Workbox is loaded 🎉`);
//my code
} else {
console.log(` Boo! Workbox didn't load 😬`);
} But in the end I lost quite some hours trying to set up vue(cli), vuetify and pwa and came to the conclusion that a vanilla service-worker api does work fine, is more robust and despite being low-level allows me to understand what's going on and bend the code to my own needs |
iirc, workbox-webpack-plugin v5 has the advantage of bundling the code alongside and offline (edit: https://github.com/GoogleChrome/workbox/releases/tag/v5.0.0), while v4 still implictly includes calls to googleapis.com. Because of this, an upgrade would be great, but until the next major version, I found setting the version manually (see Linus' answer) works very well |
@luffs I tried this however I get: Any idea. Is there a way to move to Workbox v5 without yarn (but npm). I de-installed the Vue PWA plugin. |
Ok I found the solution:
service-worker.js:
|
I went ahead and removed So I backtracked and tried to add the following resolutions:
It seems to be working. I had to update Example of what my service-worker.js looks like
I'll keep testing it but if anyone else has done this i'd like to hear if there's anything else. |
This only works if you use yarn on dev, your deployments, containers and are okay with breaking pnpm and glitch. You could use the post install lock workarounds, but resolutions are problematic to begin with. Despite me using the PWA plugin, I'll use the other more direct mappings as I'm starting to heavily rely on workers for things. #5838 The path forward is clearly one where service workers work offline, with Webpack 5 HMR, are always on in dev mode and are integral to regular development. As such, I think @lyffs method should become the vue cli norm, not the exception. |
Latest release (@vue/cli v5) is now using workbox 6. |
What problem does this feature solve?
ref: https://github.com/GoogleChrome/workbox/releases/tag/v5.0.0
Workbox v5.0 fix many problems, we want to use workbox 5.0 version as soon as possible!
Thank you very much!
What does the proposed API look like?
Please upgrade workbox-webpack-plugin to v5.0.
The text was updated successfully, but these errors were encountered: