Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"_ci-releaseElectronApp": "cd src-electron && npm run build:appimage && cd ..",
"_ci-update-phcode-build": "node src-build/update-phcode-build.js",
"serve": "node src-build/serveForPlatform.js",
"serve:dist": "node src-build/serveForPlatform.js --dist",
"serve:tauri": "node src-build/serveForPlatform.js tauri",
"serve:electron": "node src-build/serveForPlatform.js electron",
"postinstall": "node ./src-build/downloadNodeBinary.js && node ./src-build/setupElectron.js",
Expand All @@ -49,4 +50,4 @@
"branch": "tauri",
"commit": "deb309997d34383ffc01c623902537ad095c79f3"
}
}
}
19 changes: 17 additions & 2 deletions src-build/serveForPlatform.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,15 @@ function createTauriDevConfig() {
}

// Get target from CLI arg, or detect from platform
const cliArg = process.argv[2];
const cliArgs = process.argv.slice(2).filter(arg => !arg.startsWith('--'));
const cliArg = cliArgs[0];
let target;

if (cliArg === 'tauri' || cliArg === 'electron') {
target = cliArg;
} else if (cliArg) {
console.error(`Unknown target: ${cliArg}`);
console.error('Usage: npm run serve [tauri|electron]');
console.error('Usage: npm run serve [tauri|electron] [--dist]');
process.exit(1);
} else {
// Auto-detect: Linux uses Electron, Windows/Mac use Tauri
Expand All @@ -65,6 +66,13 @@ if (target !== recommendedTarget) {
console.warn(y(`╚${border}╝\n`));
}

const serveDist = process.argv.includes('--dist');

if (serveDist && target === "tauri") {
console.error('Error: --dist flag is only supported with Electron, not Tauri.');
process.exit(1);
}

console.log(`Platform: ${platform}, target: ${target}`);

// Run platform-specific command
Expand Down Expand Up @@ -95,6 +103,13 @@ if (target === "tauri") {
const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf8'));
const effectiveConfig = JSON.parse(readFileSync(configDest, 'utf8'));
effectiveConfig.version = packageJson.version;

// When --dist flag is passed, serve from ../phoenix/dist instead of ../phoenix/src
if (serveDist) {
console.log('Serving from ../phoenix/dist (--dist mode)');
effectiveConfig.phoenixLoadURL = effectiveConfig.phoenixLoadURL.replace('/src/', '/dist/');
}

writeFileSync(configDest, JSON.stringify(effectiveConfig, null, 2));

console.log('Starting Electron...');
Expand Down
Loading