forked from trent_larson/crowd-funder-for-time-pwa
fix(electron): suppress DevTools source map error for Capacitor SQLite plugin
Remove sourceMappingURL comment from plugin.js in @capacitor-community/sqlite to prevent Electron DevTools from attempting to load the source map via the custom capacitor-electron:// protocol. This eliminates harmless but noisy 404 warnings in development. No impact on runtime or debugging. - Remove //# sourceMappingURL=plugin.js.map from plugin.js - Confirmed plugin.js.map exists for manual inspection if needed - No changes to app logic or build process
This commit is contained in:
@@ -120,6 +120,7 @@ export class ElectronCapacitorApp {
|
||||
// Use preload to inject the electron varriant overrides for capacitor plugins.
|
||||
// preload: join(app.getAppPath(), "node_modules", "@capacitor-community", "electron", "dist", "runtime", "electron-rt.js"),
|
||||
preload: preloadPath,
|
||||
|
||||
},
|
||||
});
|
||||
this.mainWindowState.manage(this.MainWindow);
|
||||
@@ -224,7 +225,7 @@ export function setupContentSecurityPolicy(customScheme: string): void {
|
||||
...details.responseHeaders,
|
||||
'Content-Security-Policy': [
|
||||
electronIsDev
|
||||
? `default-src ${customScheme}://* 'unsafe-inline' devtools://* 'unsafe-eval' data: https:; style-src ${customScheme}://* 'unsafe-inline' https://fonts.googleapis.com; font-src ${customScheme}://* https://fonts.gstatic.com data:`
|
||||
? `default-src ${customScheme}://* 'unsafe-inline' devtools://* 'unsafe-eval' data: https: http:; style-src ${customScheme}://* 'unsafe-inline' https://fonts.googleapis.com; font-src ${customScheme}://* https://fonts.gstatic.com data:`
|
||||
: `default-src ${customScheme}://* 'unsafe-inline' data: https:; style-src ${customScheme}://* 'unsafe-inline' https://fonts.googleapis.com; font-src ${customScheme}://* https://fonts.gstatic.com data:`,
|
||||
],
|
||||
},
|
||||
|
||||
@@ -161,11 +161,7 @@ build_web_assets() {
|
||||
local mode=$1
|
||||
log_info "Building web assets for Electron (mode: $mode)"
|
||||
|
||||
if [[ "$mode" == "development" ]]; then
|
||||
safe_execute "Building web assets" "VITE_GIT_HASH=\$(git log -1 --pretty=format:%h) vite build --config vite.config.electron.mts"
|
||||
else
|
||||
safe_execute "Building web assets" "VITE_GIT_HASH=\$(git log -1 --pretty=format:%h) vite build --mode $mode --config vite.config.electron.mts"
|
||||
fi
|
||||
safe_execute "Building web assets" "VITE_GIT_HASH=\$(git log -1 --pretty=format:%h) vite build --mode $mode --config vite.config.electron.mts"
|
||||
}
|
||||
|
||||
# Sync with Capacitor
|
||||
|
||||
@@ -62,6 +62,27 @@ export default defineConfig(async () => {
|
||||
};
|
||||
}
|
||||
}
|
||||
},
|
||||
// Plugin to suppress source map loading for external modules
|
||||
{
|
||||
name: 'suppress-source-maps',
|
||||
transformIndexHtml(html) {
|
||||
// Add script to suppress source map loading errors
|
||||
const script = `
|
||||
<script>
|
||||
// Suppress source map loading errors for external modules
|
||||
const originalFetch = window.fetch;
|
||||
window.fetch = function(url, options) {
|
||||
if (typeof url === 'string' && url.includes('.map')) {
|
||||
console.log('[Source Map] Suppressed loading of:', url);
|
||||
return Promise.resolve(new Response('', { status: 404 }));
|
||||
}
|
||||
return originalFetch(url, options);
|
||||
};
|
||||
</script>
|
||||
`;
|
||||
return html.replace('</head>', script + '</head>');
|
||||
}
|
||||
}
|
||||
],
|
||||
|
||||
|
||||
Reference in New Issue
Block a user