WIP: disabling absurd-sql when using Capacitor SQLite

This commit is contained in:
Matthew Raymer
2025-05-27 13:15:41 +00:00
parent 7b4f9d6556
commit f0d8fdf98c
5 changed files with 151 additions and 33 deletions

View File

@@ -2,11 +2,18 @@
import { register } from "register-service-worker";
// Only register service worker if explicitly enabled and in production
if (
process.env.VITE_PWA_ENABLED === "true" &&
process.env.NODE_ENV === "production"
) {
// Check if we're in an Electron environment
const isElectron = process.env.VITE_PLATFORM === 'electron' ||
process.env.VITE_DISABLE_PWA === 'true' ||
window.navigator.userAgent.toLowerCase().includes('electron');
// Only register service worker if:
// 1. Not in Electron
// 2. PWA is explicitly enabled
// 3. In production mode
if (!isElectron &&
process.env.VITE_PWA_ENABLED === "true" &&
process.env.NODE_ENV === "production") {
register(`${process.env.BASE_URL}sw.js`, {
ready() {
console.log("Service worker is active.");
@@ -34,6 +41,12 @@ if (
});
} else {
console.log(
"Service worker registration skipped - not enabled or not in production",
`Service worker registration skipped - ${
isElectron
? "running in Electron"
: process.env.VITE_PWA_ENABLED !== "true"
? "PWA not enabled"
: "not in production mode"
}`
);
}