The improved npm start command now:
- Builds React app first - Ensures the bundle exists before Electron starts
- Starts webpack in watch mode - Automatically rebuilds when files change
- Waits for bundle - Electron waits for the initial build to complete
- Starts Electron - Launches the app with hot reload enabled
npm startThis will:
- Build the React app initially
- Start webpack in watch mode
- Launch Electron when ready
- Enable hot reload for both React and Electron
- Open
src/renderer.jsx - Change the title text:
🚀 CDC Electron Starterkit→🔥 Hot Reload Working! - Save the file
- The app should automatically update without restarting
- Open
src/style.css - Change the gradient colors in the
bodyselector - Save the file
- The styling should update immediately
- Open
src/main.js - Change the window size (width/height)
- Save the file
- Electron should restart automatically with new window size
{
"start": "npm run build:renderer:dev && npm-run-all -p watch:renderer start:electron:delayed",
"start:electron:delayed": "cross-env NODE_ENV=development wait-on dist/renderer.bundle.js && electron .",
"watch:renderer": "webpack --mode=development --watch"
}- Initial Build:
npm run build:renderer:devensures bundle exists - Parallel Execution:
npm-run-all -pruns webpack watch and electron together - Wait-on: Ensures Electron waits for webpack bundle before starting
- Electron-reloader: Watches main process files and restarts when changed
- Webpack Watch: Rebuilds React app when source files change
- React Files (
src/renderer.jsx,src/style.css): Webpack rebuilds → Browser refreshes - Main Process (
src/main.js,src/preload.js): Electron-reloader restarts app - HTML (
src/index.html): Electron-reloader restarts app
-
Check if both processes are running:
- Webpack should show "webpack compiled successfully"
- Electron should show the app window
-
Check for errors:
- Look for webpack compilation errors
- Check Electron console for JavaScript errors
-
Manual restart:
- Stop with
Ctrl+C - Run
npm run clean - Run
npm startagain
- Stop with
- Babel caching is enabled for faster rebuilds
- Source maps are optimized for development
- Watch options are tuned for better performance
# Start development (recommended)
npm start
# Clean build artifacts if needed
npm run clean
# Build for production
npm run build:renderer
# Run tests
npm testThe hot reload setup now provides a smooth development experience with automatic rebuilding and reloading for both React and Electron components.