mirror of
https://github.com/aleleba/create-react-ssr.git
synced 2025-01-08 04:56:57 -06:00
21 lines
541 B
TypeScript
21 lines
541 B
TypeScript
import { Workbox } from 'workbox-window';
|
|
import packageJson from './package.json';
|
|
|
|
const serviceWorkerRegistration = () => {
|
|
if ('serviceWorker' in navigator) {
|
|
const wb = new Workbox('service-worker.js');
|
|
|
|
wb.addEventListener('installed', event => {
|
|
if(event.isUpdate){
|
|
if(confirm('New app update is avaible, Click Ok to refresh')){
|
|
window.location.reload();
|
|
};
|
|
console.log(`Se actualiza la app a version ${packageJson.version}`);
|
|
};
|
|
});
|
|
|
|
wb.register();
|
|
};
|
|
};
|
|
|
|
export default serviceWorkerRegistration; |