- aggiornamento con proj RISO. postcss, pwa.
This commit is contained in:
@@ -1,25 +1,23 @@
|
||||
/* eslint-disable no-undef */
|
||||
import { cleanupOutdatedCaches, precacheAndRoute } from 'workbox-precaching';
|
||||
import { precacheAndRoute } from 'workbox-precaching';
|
||||
import { registerRoute } from 'workbox-routing';
|
||||
import { clientsClaim, setCacheNameDetails, skipWaiting } from 'workbox-core';
|
||||
import { setCacheNameDetails } from 'workbox-core';
|
||||
import {
|
||||
NetworkFirst,
|
||||
NetworkOnly,
|
||||
StaleWhileRevalidate,
|
||||
CacheFirst,
|
||||
} from 'workbox-strategies';
|
||||
|
||||
const ENABLE_DYNAMIC_CACHING = false;
|
||||
import { CacheableResponsePlugin } from 'workbox-cacheable-response';
|
||||
import { ExpirationPlugin } from 'workbox-expiration';
|
||||
|
||||
const isIOS = /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream;
|
||||
|
||||
|
||||
importScripts('https://storage.googleapis.com/workbox-cdn/releases/6.5.4/workbox-sw.js');
|
||||
|
||||
self.addEventListener('install', () => self.skipWaiting());
|
||||
self.addEventListener('install', () => {
|
||||
console.log('Service Worker: Skip...');
|
||||
self.skipWaiting()
|
||||
});
|
||||
self.addEventListener('activate', (event) => {
|
||||
console.log('Service Worker: Activated');
|
||||
// console.log('CLAIM');
|
||||
//event.waitUntil(self.clients.claim())
|
||||
|
||||
@@ -39,7 +37,12 @@ const VITE_APP_VERSION = "1.1.23";
|
||||
|
||||
console.log(' [ VER-' + VITE_APP_VERSION + ' ] _---------________------ PAO: this is my custom service worker');
|
||||
|
||||
importScripts('js/idb.js', 'js/storage.js');
|
||||
try {
|
||||
importScripts('/js/idb.js', '/js/storage.js');
|
||||
console.log('Local scripts imported successfully.');
|
||||
} catch (error) {
|
||||
console.error('Failed to import local scripts:', error);
|
||||
}
|
||||
|
||||
let port = self.location.hostname.startsWith('test') ? 3001 : 3000;
|
||||
let ISTEST = self.location.hostname.startsWith('test');
|
||||
|
||||
@@ -5,14 +5,23 @@
|
||||
|
||||
import { register } from 'register-service-worker'
|
||||
|
||||
register(import.meta.env.VITE_SERVICE_WORKER_FILE ? import.meta.env.VITE_SERVICE_WORKER_FILE : '', {
|
||||
console.log('SWFILE: ', process.env.VITE_SERVICE_WORKER_FILE);
|
||||
|
||||
register(process.env.VITE_SERVICE_WORKER_FILE, {
|
||||
scope: '/',
|
||||
/************* ✨ Codeium Command ⭐ *************/
|
||||
/**
|
||||
* When the app has finished populating the caches and the service worker has taken control of the page,
|
||||
* this callback will be triggered. It's a good place to do something with the registration such as post a message
|
||||
* to the waiting service worker, or add an event listener for future push events.
|
||||
*/
|
||||
/****** 37dbd402-a66f-4a9b-9ead-63e4617559c1 *******/
|
||||
ready() {
|
||||
console.log('READY::: App is being served from cache by a service worker ' + import.meta.env.VITE_SERVICE_WORKER_FILE)
|
||||
},
|
||||
|
||||
registered(registration) { // registration -> a ServiceWorkerRegistration instance
|
||||
console.log('REGISTERED::: !!!', import.meta.env.VITE_SERVICE_WORKER_FILE)
|
||||
console.log('REGISTERED::: !!!', process.env.VITE_SERVICE_WORKER_FILE)
|
||||
},
|
||||
cached(registration) {
|
||||
console.log('CACHED::: Content has been cached for offline use.')
|
||||
|
||||
Reference in New Issue
Block a user