Library Affected:
webpack-plugin-workbox
Currently using injectManifest doesn't remove old precacheManifest.js files from the dist directory. Every time you build your app and something has changed Workbox generates of course a new precacheManifest.js file since the hash has changed. Each build adds a new file.
Is deletion of old precacheManifest files something that should be incorporated into Workbox? Or is it left out by thought and decision?
ALSO: is it completely safe to remove the old files from the server? Is it possible to cause some harm to already registered SWs?
I am having the same issue. Is there anyway in development to make it so my dist folder does not have a 100 precacheManifest files?
Is deletion of old precacheManifest files something that should be incorporated into Workbox? Or is it left out by thought and decision?
I wouldn't say that the current behavior was arrived at through a specific decision, but rather that it's what seemed like the natural approach for this sort of plugin.
My understanding of common webpack setups if that if a developer wants to ensure that their output directory is kept free of clutter from previous builds, using the approach described at https://webpack.js.org/guides/output-management/#cleaning-up-the-dist-folder is the best practice.
Is that approach something that would work for you?
Yes, removing them in the beginning of the build process would of course work for me. Not sure how other people and projects see it – but you're correct about keeping the build dir clean of previous artifacts.
Regarding a much earlier question:
ALSO: is it completely safe to remove the old files from the server? Is it possible to cause some harm to already registered SWs?
Service workers are meant to aggressively cache anything referenced via importScripts(), so once a service worker has installed and loaded the precache manifest once, it shouldn't matter if it then disappears from the web server as part of a fresh deployment.
Most helpful comment
Regarding a much earlier question:
Service workers are meant to aggressively cache anything referenced via
importScripts(), so once a service worker has installed and loaded the precache manifest once, it shouldn't matter if it then disappears from the web server as part of a fresh deployment.