Files

22 lines
845 B
PowerShell

# 前端建置輔助腳本(使用 Codex 桌面自帶的 node,不需 npm)
# 用法: .\scripts\build_frontend.ps1 # production build
# .\scripts\build_frontend.ps1 -Dev # dev server (vite)
# 注意: esbuild 會掃描目錄樹;在受限環境(沙盒)執行失敗時,
# 請改用一般終端機執行本腳本。
param([switch]$Dev)
$ErrorActionPreference = 'Stop'
$node = 'C:\Users\ckliu\.cache\codex-runtimes\codex-primary-runtime\dependencies\node\bin\node.exe'
$root = Split-Path -Parent $PSScriptRoot
$client = Join-Path $root 'client'
if (-not (Test-Path $node)) { throw "找不到 node: $node" }
Push-Location $client
try {
if ($Dev) {
& $node node_modules\vite\bin\vite.js
} else {
& $node node_modules\vite\bin\vite.js build
}
exit $LASTEXITCODE
} finally {
Pop-Location
}