Reputation: 895
My question is is this possible to force webpack-dev-server to update the service-worker file without manual reloading the whole server? I'm using workbox-webpack-plugin with injectManifest option. It's looking like this:
new InjectManifest({
swSrc: './sw-base.js',
swDest: 'sw.js',
}),
This is sw-base.js
importScripts(
'https://storage.googleapis.com/workbox-cdn/releases/5.0.0/workbox-sw.js',
);
workbox.setConfig({ debug: false });
self.skipWaiting();
workbox.routing.registerRoute(
new RegExp(/\.(png|jpg)/),
new workbox.strategies.StaleWhileRevalidate({
cacheName: 'images',
}),
);
workbox.precaching.precacheAndRoute(self.__WB_MANIFEST);
When I'm changing the sw-base.js file (for example the cacheName) I have to reload whole webpack-dev-server to apply changes.
So is this possible to make dev-server to auto reload on sw-base.js change?
Thanks from advance :3
Upvotes: 2
Views: 1990
Reputation: 895
I'm answering own question but it may help others, who knows. So most probably, that is not possible using webpack-dev-server.
However you can make a quite effective build for working with workbox and webpack.
Steps:
For faster development you can enable "update on reload" option in ChromeDevTools/application. It automatically unregisters and registers new service worker on reload.
Cheers
Upvotes: 2