Decouple frontend from Rails, establish pnpm workspace dev workflow

Strip the Chatwoot frontend down to a standalone Vite + Vue 3 SPA that talks
directly to the GoChat Go backend — no Ruby/Rails required.

Deleted from frontend/ (all Rails-only):
- Ruby: Gemfile, Gemfile.lock, config.ru, Capfile, Rakefile, bin/ (binstubs),
  config/ (application/boot/environment/routes/initializers/environments/locales),
  app/helpers/ (*.rb), app/views/ (ERB/jbuilder), app/assets/ (administrate scss)
- Enterprise overlay (enterprise/ — pure Ruby/jbuilder, zero JS)
- Infra: Procfile*, docker-compose*, docker/, deployment/, swagger/, .circleci/,
  .devcontainer/, .qlty/, .codegraph/, .windsurf/, .github/, .vscode/, .husky/
- Lint/config: .rubocop.yml, .scss-lint.yml, .rspec, rubocop/, .bundler-audit.yml,
  .annotaterb.yml, .all-contributorsrc, crowdin.yml, histoire.config.ts, etc.
- Stale frontend/pnpm-lock.yaml (replaced by root workspace lockfile)

Kept (frontend build essentials):
- app/javascript/ (all Vue SPA source — dashboard/widget/sdk/portal/superadmin/survey/v3)
- package.json, vite.config.ts, tailwind.config.js, postcss.config.js
- theme/, vitest.setup.js, .prettierrc

Key decoupling changes:
- vite.config.ts: removed vite-plugin-ruby, added explicit rollupOptions.input
  for all 7 entrypoints + dev-server proxy (/api,/platform,/cable,/health → GoChat)
- index.html: created static SPA entry that injects window.chatwootConfig /
  window.globalConfig (previously done by Rails ERB vueapp.html.erb)
- package.json: renamed @gochat/frontend, removed vite-plugin-ruby/histoire/husky,
  scripts now use plain vite dev/build
- tailwind.config.js: removed enterprise ERB content paths
- markdownEmbeds.js: relocated markdown_embeds.yml into app/javascript/dashboard/config/

Root pnpm workspace:
- package.json: dev:backend (air), dev:frontend (vite), dev (concurrently)
- pnpm-workspace.yaml: frontend as workspace package
- .gitignore: node_modules/, frontend/dist/, frontend build artifacts

Verified: pnpm install + vite build succeeds (4446 modules, all 7 entrypoints
produce JS+CSS chunks in dist/).
This commit is contained in:
2026-07-07 15:37:24 +08:00
parent 321c61aaae
commit 1535e6cd55
1103 changed files with 8628 additions and 186164 deletions
+22 -5
View File
@@ -43,12 +43,11 @@ backend/ # Go 后端(单仓库 monorepo 子目录)
scripts/ # 迁移、种子、健康检查等脚本
tests/
e2e/ # 端到端测试(Auth/AccountCRUD/CRM)
frontend/ # Chatwoot Vue 3 前端(vendor 过来后续定制)
frontend/ # Chatwoot Vue 3 前端(已从 Rails 解耦,独立 Vite SPA)
app/javascript/ # Vue SPA 源码(dashboard/widget/sdk/portal/superadmin)
app/views/ # ERB 模板(vite-plugin-ruby entrypoint 解析依赖)
enterprise/ # 企业版前端覆盖层
config/vite.json # Vite-Rails 桥接配置
package.json # pnpm + Vite + Vue 3 工具链
index.html # 静态入口(注入 window.chatwootConfig)
vite.config.ts # 标准 Vite 配置(dev server 代理 API 到 GoChat 后端)
package.json # @gochat/frontend(pnpm + Vite + Vue 3)
deploy/ # 部署相关
docker/ # Dockerfile + docker-compose(dev/prod/test)
quickstart/ # 本地/UAT 一键启动 Compose 栈
@@ -107,6 +106,24 @@ docker compose --profile seed run --rm seed
详见 [deploy/quickstart/README.md](deploy/quickstart/README.md)。
### 前端开发
前端已从 Chatwoot 的 Rails 耦合中解耦,现为独立的 Vite + Vue 3 SPA,直连 GoChat 后端。
```bash
# 仓库根目录统一启动
pnpm install # 安装所有 workspace 依赖
pnpm dev:backend # 启动 Go 后端(air 热重载,端口 3000)
pnpm dev:frontend # 启动 Vite dev server(端口 3036,API 代理到 :3000)
pnpm dev # 同时启动前后端
# 单独构建前端
pnpm build:frontend # 生产构建 → frontend/dist/
```
Vite dev server 会将 `/api`、`/platform`、`/cable`、`/health` 代理到 GoChat 后端
(默认 `http://127.0.0.1:3000`,可通过 `VITE_API_HOST` 环境变量覆盖)。
## 环境配置
GoChat 使用 **Viper 多环境叠加**机制: