forked from trent_larson/crowd-funder-for-time-pwa
WIP: disabling absurd-sql when using Capacitor SQLite
This commit is contained in:
@@ -53,24 +53,46 @@ export default defineConfig(async () => {
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'remove-sw-imports',
|
||||
transform(code: string, id: string) {
|
||||
if (
|
||||
id.includes('registerServiceWorker') ||
|
||||
id.includes('register-service-worker') ||
|
||||
id.includes('sw_scripts') ||
|
||||
id.includes('PushNotificationPermission') ||
|
||||
code.includes('navigator.serviceWorker')
|
||||
) {
|
||||
return {
|
||||
code: code
|
||||
.replace(/import.*registerServiceWorker.*$/mg, '')
|
||||
.replace(/import.*register-service-worker.*$/mg, '')
|
||||
.replace(/navigator\.serviceWorker/g, 'undefined')
|
||||
.replace(/if\s*\([^)]*serviceWorker[^)]*\)\s*{[^}]*}/g, '')
|
||||
};
|
||||
name: 'remove-sw-imports',
|
||||
transform(code: string, id: string) {
|
||||
// Remove service worker imports and registrations
|
||||
if (id.includes('registerServiceWorker') ||
|
||||
id.includes('register-service-worker') ||
|
||||
id.includes('sw_scripts') ||
|
||||
id.includes('PushNotificationPermission') ||
|
||||
code.includes('navigator.serviceWorker')) {
|
||||
return {
|
||||
code: code
|
||||
.replace(/import.*registerServiceWorker.*$/mg, '')
|
||||
.replace(/import.*register-service-worker.*$/mg, '')
|
||||
.replace(/navigator\.serviceWorker/g, 'undefined')
|
||||
.replace(/if\s*\([^)]*serviceWorker[^)]*\)\s*{[^}]*}/g, '')
|
||||
.replace(/import.*workbox.*$/mg, '')
|
||||
.replace(/importScripts\([^)]*\)/g, '')
|
||||
};
|
||||
}
|
||||
return code;
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'remove-sw-files',
|
||||
enforce: 'pre',
|
||||
resolveId(id: string) {
|
||||
// Prevent service worker files from being included
|
||||
if (id.includes('sw.js') ||
|
||||
id.includes('workbox') ||
|
||||
id.includes('registerSW.js') ||
|
||||
id.includes('manifest.webmanifest')) {
|
||||
return '\0empty';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
load(id: string) {
|
||||
if (id === '\0empty') {
|
||||
return 'export default {}';
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
ssr: {
|
||||
|
||||
Reference in New Issue
Block a user