niucloud/admin/scripts/run-vite.cjs
wangchen14709853322 3e71008192 v2.0-beta-20260626
v2框架公测版测试流程请看v2.0-beta.md
2026-06-26 17:56:38 +08:00

31 lines
820 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* 统一用 node 直接启动 vite避免 Windows 上 npx + shell 触发 spawn EPERM
*
* 用法node scripts/run-vite.cjs build --config vite.config.shared.ts
*/
const path = require('path')
const { spawnSync } = require('child_process')
const ROOT = path.resolve(__dirname, '..')
const VITE_BIN = path.join(ROOT, 'node_modules', 'vite', 'bin', 'vite.js')
require('./ensure-esbuild.cjs')
const args = process.argv.slice(2)
if (!args.length) {
console.error('Usage: node scripts/run-vite.cjs <vite-args...>')
process.exit(1)
}
const r = spawnSync(process.execPath, [VITE_BIN, ...args], {
cwd: ROOT,
env: {
...process.env,
NODE_OPTIONS: process.env.NODE_OPTIONS || '--max-old-space-size=4096'
},
stdio: 'inherit',
shell: false
})
process.exit(r.status ?? 1)