Development Setup
Install Dependencies
Install all required npm packages including Electron, React, and CodeMirror:This also runs
electron-builder install-app-deps via the postinstall script to install native dependencies.Start Development Server
Run the Vite development server for hot module reloading:The dev server starts at
http://localhost:5173 by default.The app detects whether it’s running in Electron. If you only run
npm run dev, you’ll see a message to launch Electron for full functionality.Build Commands
All build commands are defined inpackage.json:9-16.
Development Builds
Production Builds
Build Renderer Process
Compile TypeScript and build the React app with Vite:This runs:
tsc- Type checkingvite build- Bundles React app todist/
The build output goes to the
dist/ directory.Build Main Process
Compile the Electron main process and preload script:This executes
build-electron.mjs which uses esbuild to bundle:electron/main.ts→dist-electron/main.cjselectron/preload.ts→dist-electron/preload.cjs
Electron Build Process
Build Configuration
The Electron Builder configuration is defined inpackage.json:66-85:
Build Outputs
dist/
Renderer ProcessVite-bundled React application:
index.html- JavaScript bundles
- CSS files
- Assets
dist-electron/
Main Process & PackagesElectron files and installers:
main.cjs- Main processpreload.cjs- Preload script- Platform-specific installers (after
electron:build)
Platform-Specific Builds
macOS
dist-electron/Code Editor Thing.dmg- DMG installerdist-electron/mac/Code Editor Thing.app- Application bundle
Windows
Electron Builder auto-detects the platform. On Windows, it creates:.exeinstaller- Unpacked application directory
Modify the
build.mac section in package.json to build.win for Windows-specific settings.Linux
Add Linux configuration topackage.json:
Build Workflow
Development vs Production
| Aspect | Development | Production |
|---|---|---|
| Renderer | Vite dev server (HMR) | Static files in dist/ |
| Main Process | Rebuilt on changes | Pre-built .cjs files |
| URL | http://localhost:5173 | file:// protocol |
| DevTools | Auto-open | Disabled |
| Source Maps | Enabled | Optional |
Optimization Tips
Code Splitting
Vite automatically splits vendor code. Large dependencies like CodeMirror are bundled separately for better caching.
Asset Optimization
Vite optimizes assets during build. Place images in
src/assets/ to benefit from automatic optimization.Troubleshooting
Build fails with TypeScript errors
Build fails with TypeScript errors
Run type checking separately to see detailed errors:
Electron window shows blank screen
Electron window shows blank screen
Check the Electron dev tools console. Common issues:
- Preload script path is incorrect
- Vite dev server isn’t running
- Content Security Policy blocking resources
Native modules fail to load
Native modules fail to load
Rebuild native dependencies for Electron:This re-runs
electron-builder install-app-deps.electron-builder packaging fails
electron-builder packaging fails
Ensure all files are present:
dist/directory exists (runnpm run build)dist-electron/main.cjsexists (runnpm run build:electron)- No path errors in
package.jsonbuild config
Next Steps
Architecture
Understand the codebase structure
Contributing
Learn how to contribute changes