3.9 KiB
Electron Quick Start Guide
Prerequisites
- Node.js 18+ installed
- npm or yarn package manager
Development
To run Shakespeare as an Electron desktop app in development mode:
npm run electron:dev
This will:
- Start the Vite development server on http://localhost:5173
- Launch Electron with hot-reload support
- Open DevTools automatically for debugging
Building for Distribution
Build for Your Current Platform
npm run electron:build
This will create an installer/package for your current operating system in the electron-dist/ directory.
Build for Specific Platforms
macOS:
npm run electron:build:mac
Produces: .dmg installer and .zip archive for both Intel and Apple Silicon
Windows:
npm run electron:build:win
Produces: NSIS installer and portable .exe for both x64 and ARM64
Linux:
npm run electron:build:linux
Produces: AppImage, .deb, and .rpm packages for both x64 and ARM64
Build for All Platforms
npm run electron:build:all
⚠️ Note: Cross-platform builds have limitations:
- Building for macOS requires macOS (for code signing)
- Building Windows
.exefrom macOS/Linux works but may have limitations - Building for Linux works from any platform
Icon Setup
Good news! No icon setup is required. The build automatically uses public/shakespeare-512x512.png and converts it to the appropriate format for each platform.
If you want to customize the icons:
- Run
npm run electron:icons(requires ImageMagick) - Or manually place custom icons in
electron/resources/ - Update
electron/builder.config.jsto use the custom icons
But for most users, the default setup works perfectly!
Output Location
All built applications will be in the electron-dist/ directory:
electron-dist/
├── mac/ # macOS builds
│ ├── Shakespeare.app # Application bundle
│ └── Shakespeare.dmg # DMG installer
├── win-unpacked/ # Windows unpacked
│ └── Shakespeare.exe # Executable
├── Shakespeare Setup.exe # Windows NSIS installer
├── Shakespeare Portable.exe # Windows portable
└── shakespeare-*.AppImage # Linux AppImage
Troubleshooting
Port 5173 Already in Use
If you get an error that port 5173 is already in use:
- Stop any running Vite dev servers
- Or change the port in
vite.config.ts
Build Fails
If the build fails:
- Ensure you've run
npm run buildsuccessfully first - Check that all dependencies are installed:
npm install - Clear the dist folder:
rm -rf dist electron-dist - Try building again
Icons Not Showing
If icons don't appear in the built app:
- Verify icon files exist in
electron/resources/ - Check file names match the builder config
- Ensure icons are in the correct format (icns for Mac, ico for Windows, png for Linux)
What's Different in Electron?
When running in Electron, the app has access to:
window.electron.isElectron- Boolean flag (alwaystruein Electron)window.electron.platform()- Returns platform: 'darwin', 'win32', or 'linux'window.electron.version()- Returns app version from package.json
You can use these in your code to detect the Electron environment:
if (window.electron?.isElectron) {
console.log('Running in Electron!');
const platform = await window.electron.platform();
console.log('Platform:', platform);
}
Next Steps
- Customize the window size and appearance in
electron/main.js - Add native menus, dialogs, or other Electron features
- Configure auto-updates (see
electron/README.md) - Set up code signing for distribution (required for macOS)