Fix public asset paths for Electron compatibility

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.
This commit is contained in:
Alex Gleason committed 2025-10-24 19:54:18 -05:00
1 parent 0c1d6b48df
commit d22a56d306
3 files changed
+92 -2

No files matched your search

+2 -1
View File
@@ -2,6 +2,7 @@ import React, { useState } from 'react';
import { Link } from 'react-router-dom';
import { Button } from '@/components/ui/button';
import { Card, CardContent } from '@/components/ui/card';
import badgeSvg from '/badge.svg';
import {
ExternalLink,
Edit,
@@ -567,7 +568,7 @@ export function AppShowcaseCard({ app, onEdit, showModerationControls, hideAppro
className="flex-1"
>
<img
src="/badge.svg"
src={badgeSvg}
alt="Edit with Shakespeare"
className="h-6 hover:opacity-80 transition-opacity"
/>
+3 -1
View File
@@ -1,3 +1,5 @@
import shakespeareLogo from '/shakespeare.svg';
export interface ShakespeareLogoProps {
className?: string;
}
@@ -5,7 +7,7 @@ export interface ShakespeareLogoProps {
export function ShakespeareLogo({ className }: ShakespeareLogoProps) {
return (
<img
src="/shakespeare.svg"
src={shakespeareLogo}
alt="Shakespeare"
className={className}
/>