Merge pull request #5 from svc-design/codex/补充ui/nextjs目录makefile并更新文档
Add Next.js Makefile for macOS and docs
This commit is contained in:
commit
7da4a633eb
@ -55,3 +55,17 @@ styles/
|
||||
|
||||
## 示例代码结构
|
||||
本仓库 `ui/nextjs` 目录提供了一套最简参考实现,可直接 `npm run build && npx next export` 编译到 `ui/dist` 供 Go 服务嵌入。
|
||||
|
||||
## macOS 本地开发调试
|
||||
`ui/nextjs` 目录下新增的 `Makefile` 可在 macOS 环境一键执行常见任务:
|
||||
|
||||
```bash
|
||||
make init # 安装依赖(若未检测到 yarn 会自动使用 Homebrew 安装)
|
||||
make run # 启动开发服务
|
||||
make build # 构建生产版本
|
||||
make export # 导出静态页面到 out/
|
||||
make clean # 清理构建产物
|
||||
```
|
||||
|
||||
执行 `make info` 可查看当前 Node.js 版本,方便排查本地环境问题。
|
||||
|
||||
|
||||
35
ui/nextjs/Makefile
Normal file
35
ui/nextjs/Makefile
Normal file
@ -0,0 +1,35 @@
|
||||
# Makefile for Next.js on macOS
|
||||
|
||||
# Node.js 版本校验(可选)
|
||||
NODE_VERSION := $(shell node -v 2>/dev/null)
|
||||
YARN := $(shell command -v yarn 2>/dev/null)
|
||||
|
||||
.PHONY: init build run export clean info
|
||||
|
||||
init:
|
||||
@echo "🔧 Installing dependencies..."
|
||||
ifeq ($(YARN),)
|
||||
@echo "⚠️ Yarn not found. Installing via Homebrew..."
|
||||
brew install yarn
|
||||
endif
|
||||
yarn install
|
||||
|
||||
build:
|
||||
@echo "🔨 Building Next.js project..."
|
||||
yarn build
|
||||
|
||||
run:
|
||||
@echo "🚀 Starting local dev server..."
|
||||
yarn dev
|
||||
|
||||
export:
|
||||
@echo "📦 Exporting static site to ./out ..."
|
||||
yarn build && yarn export
|
||||
|
||||
clean:
|
||||
@echo "🧹 Cleaning build artifacts..."
|
||||
rm -rf .next out
|
||||
|
||||
info:
|
||||
@echo "🧾 Current Node.js version: $(NODE_VERSION)"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user