Closed mjseyyedi closed 5 years ago
@mjseyyedi I can see that you solved your own issue reading your SO question - great! :) I sent a PR adding info regarding this, https://github.com/NekR/offline-plugin/pull/459, if you have the time, please check it out
Hi. first of all, thanks for your great plugin. but then, I asked this question in stackoverflow but nobody answered. the problem is that, when I convert webpack 3 to 4, new service worker cannot detect file changes and clearing cache would not execute. so previous files are still applying. could you help me to find a way in which I could apply changes to new version.
here is my offline-plugin config:
new OfflinePlugin({ relativePaths: false, publicPath: '/', excludes: ['.htaccess'], caches: { main: [], optional: [':rest:'], }, safeToUseOptionalCaches: true, AppCache: false, responseStrategy: 'cache-first', autoUpdate: 1000 * 60 * 60 * 1, appShell:'/index.template.html', ServiceWorker: { output: 'service-worker.js', events: true, prefetchRequest: { credentials: 'include', mode: 'cors' } }, cacheMaps:[ { matchPath: [/^\/\w+\.html$/], to: '/', requestType: ['navigate'] }, ] }),
and this is my updating peace of code:
const runtime = require('offline-plugin/runtime'); runtime.install({ onUpdating: () => { console.log('SW Event:', 'onUpdating'); }, onUpdateReady: () => { console.log('SW Event:', 'onUpdateReady'); runtime.applyUpdate(); }, onUpdated: () => { console.log('SW Event:', 'onUpdated'); window.location.reload(); }, onUpdateFailed: () => { console.log('SW Event:', 'onUpdateFailed'); } });