This is a much cleaner solution that eliminates the need for:
- Changing base: './' in vite.config.ts
- Importing assets in components
- Any workarounds for absolute paths
How it works:
- Register app:// protocol in Electron main process
- Maps app://path/to/file to dist/path/to/file
- Allows absolute paths (/) to work naturally in Electron
- No changes needed to source code or build config
Benefits:
- vite.config.ts stays clean (no base: './' hack)
- Components use normal paths: src="/shakespeare.svg"
- Works in both browser (https://) and Electron (app://)
- This is the standard Electron approach for serving local files
Reverted:
- vite.config.ts: Removed base: './'
- ShakespeareLogo: Back to src="/shakespeare.svg"
- AppShowcaseCard: Back to src="/badge.svg"
Updated:
- electron/main.js: Added protocol.registerFileProtocol('app', ...)
- electron/main.js: Changed loadURL to app://index.html
The issue: With base: './' for Electron, absolute paths like /shakespeare.svg
don't work because they resolve to filesystem root in file:// protocol.
The solution: Import assets so Vite transforms paths at build time.
- import logo from '/shakespeare.svg' (without ?url)
- Vite automatically converts to './shakespeare.svg' with base: './'
- Works in both browser and Electron
This is cleaner than ?url suffix which is unnecessarily Vite-specific.
Fixed components:
- ShakespeareLogo: import shakespeareLogo from '/shakespeare.svg'
- AppShowcaseCard: import badgeSvg from '/badge.svg'
Added PUBLIC_ASSETS_EXPLANATION.md documenting the solution.
- Made handleCopyShakespeareURL async
- Added try-catch for modern clipboard API
- Implemented fallback using document.execCommand for older browsers or insecure contexts
- Fallback creates hidden textarea, selects text, and uses execCommand('copy')
- Improved error handling with better user feedback
- Ensures copy functionality works across different browser environments
- Added Copy icon import from lucide-react
- Created handleCopyShakespeareURL function that:
- Validates that a repository URL exists
- Encodes the URL and formats it as a Shakespeare clone URL
- Copies the formatted URL to clipboard
- Shows success/error toast notifications
- Added button below Git URL input that appears when URL is present
- Button copies the properly formatted Shakespeare clone URL (https://shakespeare.diy/clone?url=...)
- Works with GitHub, GitLab, NostrGit, and any other git repository URL