Files
mengyanote/build.bat

31 lines
975 B
Batchfile
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.
@echo off
setlocal enabledelayedexpansion
echo ============== 开始执行构建 ==============
:: 关键:添加 call 确保 npm 执行完后继续执行后续命令
call npm run build
:: 检查构建是否成功
if %errorlevel% neq 0 (
echo 【错误】构建失败!请查看上面的错误信息
pause
exit /b 1
)
echo ============== 构建成功,准备启动服务器 ==============
echo 正在进入 dist 目录...
cd dist || (
echo 【错误】找不到 dist 目录!构建可能未生成该目录
echo 当前目录:%cd% (请确认该目录下是否有 dist 文件夹)
pause
exit /b 1
)
echo ============== 服务器启动中(端口 8080 ==============
echo 提示:服务器启动后会一直运行,访问 http://localhost:8080 查看
echo 若要停止服务器,请按 Ctrl + C然后按 Y 确认
python -m http.server 8080
:: 服务器停止后执行
echo ============== 服务器已停止 ==============
pause