mirror of
https://github.com/aleleba/create-react-ssr.git
synced 2025-06-19 20:38:31 -06:00
PR-753737: Se saca el proyecto al directorio Raíz y se actualizan dependencias.
This commit is contained in:
21
serviceWorkerRegistration.ts
Normal file
21
serviceWorkerRegistration.ts
Normal file
@ -0,0 +1,21 @@
|
||||
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;
|
Reference in New Issue
Block a user