fix: rebuild propre — 1 seul bundle, plugin clean-assets avant chaque build

This commit is contained in:
Gwadaking
2026-04-08 03:08:02 -04:00
parent 9f73639f25
commit 90bee1bfe9
11 changed files with 864 additions and 9 deletions

42
backend/public/sw.js Normal file
View File

@@ -0,0 +1,42 @@
// Service Worker — Sargasse-Sentry push notifications
self.addEventListener('push', (event) => {
if (!event.data) return;
let payload;
try {
payload = event.data.json();
} catch {
payload = { title: 'Alerte sargasses', body: event.data.text() };
}
const title = payload.title ?? 'Alerte sargasses';
const options = {
body: payload.body ?? '',
icon: '/icons.svg',
badge: '/icons.svg',
tag: payload.spotId ? `sargasse-${payload.spotId}` : 'sargasse-alert',
renotify: true,
data: { url: payload.url ?? '/' },
};
event.waitUntil(self.registration.showNotification(title, options));
});
self.addEventListener('notificationclick', (event) => {
event.notification.close();
const targetUrl = event.notification.data?.url ?? '/';
event.waitUntil(
clients.matchAll({ type: 'window', includeUncontrolled: true }).then((windowClients) => {
for (const client of windowClients) {
if (client.url === targetUrl && 'focus' in client) {
return client.focus();
}
}
if (clients.openWindow) {
return clients.openWindow(targetUrl);
}
})
);
});