fix(web): use local node_modules/.bin/vite in dist-contract (#767)

Co-authored-by: Codex <codex@local>
This commit is contained in:
Lyon
2026-06-03 17:15:54 +08:00
committed by GitHub
parent 0d06a4c5fe
commit a78a4199a8
+6 -1
View File
@@ -186,8 +186,13 @@ function listFiles(dir) {
}
async function runViteBuild(rootDir, outDir) {
const localVite = path.join(rootDir, "node_modules", ".bin", "vite");
const command = fs.existsSync(localVite) ? localVite : "npx";
const args = fs.existsSync(localVite)
? ["build", "--outDir", outDir, "--emptyOutDir", "false"]
: ["--yes", "vite@5.4.10", "build", "--outDir", outDir, "--emptyOutDir", "false"];
await new Promise((resolve, reject) => {
const child = spawn("bun", ["x", "vite", "build", "--outDir", outDir, "--emptyOutDir", "false"], { cwd: rootDir, stdio: ["ignore", "inherit", "inherit"] });
const child = spawn(command, args, { cwd: rootDir, stdio: ["ignore", "inherit", "inherit"] });
child.on("error", reject);
child.on("exit", (code) => {
if (code === 0) resolve();