mirror of
https://github.com/amitwh/markdown-converter.git
synced 2026-08-02 18:10:18 +05:30
fix(app): add Vite dev workflow, fix onLayout prop, fix icon path, allow Google Fonts CSP
The v5.0.0 React UI redesign shipped without a working dev workflow — `npm start` only ran `electron .` which loaded the source index.html that references raw .tsx files. The browser couldn't execute them, so the app rendered an empty #root and the user saw 'lot of errors'. This commit restores a real dev workflow: 1. **Vite dev server wired into npm scripts** — added `concurrently` + `wait-on` as devDeps. `npm run dev` now runs Vite (port 5173) and Electron together with `wait-on tcp:5173` so Electron only starts after the dev server is ready. 2. **Main process loads Vite URL in dev, dist/ in prod** — window module now checks `process.env.VITE_DEV_SERVER_URL` and `app.isPackaged` to decide what to load. Production still loads the built `dist/renderer/index.html`. 3. **Fixed ReferenceError: app is not defined** — window module referenced `app.isPackaged` but only imported `BrowserWindow`. Added `app` to the destructured import. 4. **Fixed wrong icon path** — window creation used `../../assets/icon.png` from src/main/window/ which resolved to `src/assets/icon.png` (doesn't exist). Icon lives at project root, so path is now `../../../assets/icon.png`. 5. **Allowed Google Fonts in CSP** — the strict CSP (`font-src 'self' data:`, `connect-src 'self'`) blocked the preconnect/css link to fonts.googleapis.com / .gstatic.com. Added both domains so Plus Jakarta Sans loads. 6. **Renamed onLayout → onLayoutChange** in AppShell — react-resizable-panels v4 renamed the prop. The v1 name was being spread to a DOM div and React logged 'Unknown event handler property' warnings. Test mock updated for parity. 7. **show: false → show: true** — ready-to-show was hanging on this Wayland/container combo. Now the window is shown immediately on create. Verified end-to-end: - 305/305 vitest tests pass - Vite dev server starts on :5173 - Electron loads localhost:5173 and React mounts - Header 'MarkdownConverter' + sidebar with 'No files open' visible - No onLayout warnings after HMR - All blocked errors resolved
This commit is contained in:
+8
-1
@@ -5,6 +5,11 @@
|
||||
"main": "src/main/index.js",
|
||||
"scripts": {
|
||||
"start": "electron .",
|
||||
"dev:renderer": "vite --config vite.renderer.config.ts",
|
||||
"dev:electron": "wait-on tcp:5173 && cross-env VITE_DEV_SERVER_URL=http://localhost:5173 electron . -- --disable-gpu --disable-software-rasterizer --disable-dev-shm-usage",
|
||||
"dev": "concurrently -k -n vite,electron -c blue,green \"npm:dev:renderer\" \"npm:dev:electron\"",
|
||||
"build:renderer": "vite build --config vite.renderer.config.ts",
|
||||
"preview": "npm run build:renderer && electron .",
|
||||
"test": "jest",
|
||||
"test:watch": "jest --watch",
|
||||
"test:coverage": "jest --coverage",
|
||||
@@ -60,6 +65,7 @@
|
||||
"autoprefixer": "^10.5.0",
|
||||
"class-variance-authority": "^0.7.1",
|
||||
"clsx": "^2.1.1",
|
||||
"concurrently": "^10.0.3",
|
||||
"cross-env": "^10.0.0",
|
||||
"electron": "^41.1.1",
|
||||
"electron-builder": "^26.0.12",
|
||||
@@ -78,7 +84,8 @@
|
||||
"tailwindcss-animate": "^1.0.7",
|
||||
"typescript": "^6.0.3",
|
||||
"vite": "^8.0.16",
|
||||
"vitest": "^4.1.8"
|
||||
"vitest": "^4.1.8",
|
||||
"wait-on": "^9.0.10"
|
||||
},
|
||||
"dependencies": {
|
||||
"@codemirror/autocomplete": "^6.20.1",
|
||||
|
||||
Reference in New Issue
Block a user