Skip to content

Commit 56fd27b

Browse files
committed
fix: npm run serve not working in windows
1 parent be7d1f9 commit 56fd27b

1 file changed

Lines changed: 28 additions & 1 deletion

File tree

src-build/serveForPlatform.js

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,31 @@ import {copyFileSync, readFileSync, writeFileSync} from "fs";
66

77
const {platform} = getPlatformDetails();
88

9+
function createTauriDevConfig() {
10+
const tauriDir = resolve("src-tauri");
11+
const tauriConfigPath = resolve(tauriDir, "tauri.conf.json");
12+
const tauriLocalConfigPath = resolve(tauriDir, "tauri-local.conf.json");
13+
14+
console.log('Creating Tauri dev config...');
15+
const configJson = JSON.parse(readFileSync(tauriConfigPath, 'utf8'));
16+
17+
// Override window URLs for dev mode
18+
const devUrl = configJson.build.devPath; // "http://localhost:8000/src/"
19+
20+
// Main window - remove hardcoded URL so devPath is used
21+
if (configJson.tauri.windows[0]) {
22+
delete configJson.tauri.windows[0].url;
23+
}
24+
25+
// fileDrop window - point to dev server
26+
if (configJson.tauri.windows[2]) {
27+
configJson.tauri.windows[2].url = devUrl + "drop-files.html";
28+
}
29+
30+
writeFileSync(tauriLocalConfigPath, JSON.stringify(configJson, null, 4));
31+
console.log('Dev config written to:', tauriLocalConfigPath);
32+
}
33+
934
// Get target from CLI arg, or detect from platform
1035
const cliArg = process.argv[2];
1136
let target;
@@ -49,8 +74,10 @@ if (target === "tauri") {
4974
console.log('Setting up src-node...');
5075
await execa("npm", ["run", "_make_src-node"], {stdio: "inherit"});
5176

77+
createTauriDevConfig();
78+
5279
console.log('Starting Tauri dev server...');
53-
await execa("npx", ["tauri", "dev"], {stdio: "inherit"});
80+
await execa("npx", ["tauri", "dev", "--config", "./src-tauri/tauri-local.conf.json"], {stdio: "inherit"});
5481
} else {
5582
const srcNodePath = resolve("../phoenix/src-node");
5683
console.log(`Running "npm install" in ${srcNodePath}`);

0 commit comments

Comments
 (0)