docs: update electron build instructions and fix electron asset paths

- Add web build prerequisite step to electron build docs
- Update electron run command to use npx
- Fix electron asset loading with improved path handling
- Add request interception for proper asset resolution
- Remove service worker files from electron build
- Improve debug logging for electron builds
This commit is contained in:
Matthew Raymer
2025-02-13 06:43:54 +00:00
parent ab29e82274
commit 01365d478c
3 changed files with 64 additions and 4 deletions

View File

@@ -18,12 +18,26 @@ async function main() {
const indexPath = path.join(wwwDir, 'index.html');
let indexContent = await fs.readFile(indexPath, 'utf8');
// Fix paths in index.html
// More comprehensive path fixing
indexContent = indexContent
// Fix absolute paths to be relative
.replace(/src="\//g, 'src="\./')
.replace(/href="\//g, 'href="\./')
.replace(/src="\.\.\/assets\//g, 'src="./www/assets/')
.replace(/href="\.\.\/assets\//g, 'href="./www/assets/');
// Fix modulepreload paths
.replace(/<link [^>]*rel="modulepreload"[^>]*href="\/assets\//g, '<link rel="modulepreload" as="script" crossorigin="" href="./assets/')
.replace(/<link [^>]*rel="modulepreload"[^>]*href="\.\/assets\//g, '<link rel="modulepreload" as="script" crossorigin="" href="./assets/')
// Fix stylesheet paths
.replace(/<link [^>]*rel="stylesheet"[^>]*href="\/assets\//g, '<link rel="stylesheet" crossorigin="" href="./assets/')
.replace(/<link [^>]*rel="stylesheet"[^>]*href="\.\/assets\//g, '<link rel="stylesheet" crossorigin="" href="./assets/')
// Fix script paths
.replace(/src="\/assets\//g, 'src="./assets/')
.replace(/src="\.\/assets\//g, 'src="./assets/')
// Fix any remaining asset paths
.replace(/(['"]\/?)(assets\/)/g, '"./assets/');
// Debug output
console.log('After path fixing, checking for remaining /assets/ paths:', indexContent.includes('/assets/'));
console.log('Sample of fixed content:', indexContent.slice(0, 500));
await fs.writeFile(indexPath, indexContent);