From ebc6c0847a34d7703ce53b091aabe23629894ed3 Mon Sep 17 00:00:00 2001 From: RumovZ Date: Wed, 17 Apr 2024 13:23:34 +0200 Subject: [PATCH] HMR on Windows (#3144) * Enable hot module reloading on Windows * Update VSC launch.json and tasks.json * Bind vite server to 127.0.0.1 (dae) Our frontend connects via IP, and on Windows, this fails if the server is bound to 'localhost' instead. --- .vscode.dist/launch.json | 13 +++++++++++-- .vscode.dist/tasks.json | 8 +------- run.bat | 2 ++ ts/vite.config.ts | 1 + 4 files changed, 15 insertions(+), 9 deletions(-) diff --git a/.vscode.dist/launch.json b/.vscode.dist/launch.json index 34028b852..b6261a9c3 100644 --- a/.vscode.dist/launch.json +++ b/.vscode.dist/launch.json @@ -6,9 +6,13 @@ "configurations": [ { "name": "Run", - "type": "python", + "type": "debugpy", "request": "launch", "program": "tools/run.py", + "args": [ + // "-p", + // "My test profile" + ], "console": "integratedTerminal", "cwd": "${workspaceFolder}", "python": "${workspaceFolder}/out/pyenv/bin/python", @@ -20,7 +24,12 @@ "PYTHONPYCACHEPREFIX": "out/pycache", "ANKIDEV": "1", "QTWEBENGINE_REMOTE_DEBUGGING": "8080", - "QTWEBENGINE_CHROMIUM_FLAGS": "--remote-allow-origins=http://localhost:8080" + "QTWEBENGINE_CHROMIUM_FLAGS": "--remote-allow-origins=http://localhost:8080", + "RUST_BACKTRACE": "1", + // "TRACESQL": "1", + // "HMR": "1", + "ANKI_API_PORT": "40000", + "ANKI_API_HOST": "127.0.0.1" }, "justMyCode": true, "preLaunchTask": "ninja" diff --git a/.vscode.dist/tasks.json b/.vscode.dist/tasks.json index 84ce2c75e..72eab9604 100644 --- a/.vscode.dist/tasks.json +++ b/.vscode.dist/tasks.json @@ -9,14 +9,8 @@ "qt" ], "windows": { - "command": "bash", - "options": { - "env": { - "PATH": "c:\\msys64\\usr\\bin;${env:Path}" - } - }, + "command": "tools/ninja.bat", "args": [ - "ninja", "pylib", "qt", "extract:win_amd64_audio" diff --git a/run.bat b/run.bat index d9d6e39ae..03acf0032 100755 --- a/run.bat +++ b/run.bat @@ -6,6 +6,8 @@ set PYTHONPYCACHEPREFIX=out\pycache set ANKIDEV=1 set QTWEBENGINE_REMOTE_DEBUGGING=8080 set QTWEBENGINE_CHROMIUM_FLAGS=--remote-allow-origins=http://localhost:8080 +set ANKI_API_PORT=40000 +set ANKI_API_HOST=127.0.0.1 call tools\ninja pylib qt extract:win_amd64_audio || exit /b 1 .\out\pyenv\scripts\python tools\run.py %* || exit /b 1 diff --git a/ts/vite.config.ts b/ts/vite.config.ts index 1ec72e4f3..7775f9714 100644 --- a/ts/vite.config.ts +++ b/ts/vite.config.ts @@ -29,6 +29,7 @@ export default defineConfig({ reportCompressedSize: false, }, server: { + host: "127.0.0.1", fs: { // Allow serving files project root and out dir allow: [