Mass replace irelax with homaroma across project
This commit is contained in:
1 parent
5e6cb851de
commit
d9c79aa900
57 files changed
+117
-117
No files matched your search
@@ -1,6 +1,6 @@
|
||||
# สรุปความแตกต่างและเป้าหมายการใช้งาน: `apps/ssr` vs `apps/website`
|
||||
|
||||
เอกสารนี้สรุปความแตกต่างเชิงสถาปัตยกรรม (Architecture) และจุดประสงค์การใช้งานระหว่าง Frontend ทั้งสองระบบในโปรเจกต์ iRelax เพื่อให้ทีมพัฒนาเข้าใจว่าควรเลือกใช้หรือพัฒนาต่อยอดที่โปรเจกต์ใด
|
||||
เอกสารนี้สรุปความแตกต่างเชิงสถาปัตยกรรม (Architecture) และจุดประสงค์การใช้งานระหว่าง Frontend ทั้งสองระบบในโปรเจกต์ HomAroma เพื่อให้ทีมพัฒนาเข้าใจว่าควรเลือกใช้หรือพัฒนาต่อยอดที่โปรเจกต์ใด
|
||||
|
||||
## ตารางเปรียบเทียบ (Comparison Table)
|
||||
|
||||
@@ -13,9 +13,9 @@
|
||||
| **จุดเด่น** | ทำงานลื่นไหลเหมือนแอปมือถือ (ไม่กระตุกตอนเปลี่ยนหน้า), เหมาะกับ Webview ในแอปพลิเคชัน | ทำ SEO ได้ดีมาก Bot สามารถอ่านข้อมูลสินค้าได้ทันที, โหลดหน้าแรกได้ไว |
|
||||
| **จุดด้อย** | ทำ SEO ได้ยาก (Bot ของ Google อาจจะอ่านข้อมูลไม่ครบเพราะต้องรอ JavaScript ทำงาน) | ต้องใช้ทรัพยากรฝั่ง Server ในการรัน (Node.js Process), ซับซ้อนกว่าในการตั้งค่า |
|
||||
| **รูปแบบการ Deploy** | **Static Files** (HTML/CSS/JS) เสิร์ฟผ่าน Nginx โดยตรง ไม่ต้องมี Node.js รันเป็นพื้นหลัง | **Node.js Server** ต้องใช้ PM2 รัน `next start` และใช้ Nginx ทำ Reverse Proxy |
|
||||
| **ตำแหน่งไฟล์บน Server**| `/home/ti/projects/MyNginxMain/nginx/html/irelaxaroma.shop/website` | `/home/ti/projects/irelax-ssr` |
|
||||
| **ตำแหน่งไฟล์บน Server**| `/home/ti/projects/MyNginxMain/nginx/html/homaroma.shop/website` | `/home/ti/projects/homaroma-ssr` |
|
||||
| **คำสั่ง Build** | `bun run build` (ได้โฟลเดอร์ `dist`) | `bun run build` (ได้โฟลเดอร์ `.next`) |
|
||||
| **Service ที่ทำงาน**| ไม่มี (Nginx จัดการทั้งหมด) | **PM2** ชื่อ process: `irelax-ssr` รันบนพอร์ต `3001` |
|
||||
| **Service ที่ทำงาน**| ไม่มี (Nginx จัดการทั้งหมด) | **PM2** ชื่อ process: `homaroma-ssr` รันบนพอร์ต `3001` |
|
||||
| **การจัดการ Routing** | `react-router-dom` (ประมวลผลที่ฝั่ง Client ทั้งหมด) | Next.js App Router (มีระบบ File-based routing) |
|
||||
| **การจัดการ State** | Zustand | React Context / Zustand / Server Components |
|
||||
| **ความเหมาะสมของระบบ Login**| เหมาะสมกับ **LINE LIFF Login** และ Token-based auth เพราะมี Context แบบ SPA | เหมาะกับ Cookie-based Auth (NextAuth/Auth.js) หรือ Session |
|
||||
@@ -44,13 +44,13 @@
|
||||
- **คำสั่ง Build:** `cd apps/website && bun run build`
|
||||
- **สิ่งที่ได้จากการ Build:** โฟลเดอร์ `dist/`
|
||||
- **ตำแหน่งไฟล์ปลายทาง (Target Directory):**
|
||||
`/home/ti/projects/MyNginxMain/nginx/html/irelaxaroma.shop/website`
|
||||
`/home/ti/projects/MyNginxMain/nginx/html/homaroma.shop/website`
|
||||
- **การจัดการ Environment:** ต้องประกาศตัวแปรแวดล้อมก่อนสั่ง Build เสมอ (เช่น `export VITE_LIFF_ID=...`) เพื่อให้ Vite ฝังค่าเข้าไปในไฟล์โค้ด
|
||||
- **การตั้งค่า Nginx ที่จำเป็น (Routing Configuration):**
|
||||
เพื่อให้ระบบ React Router ทำงานได้โดยไม่เกิด 404 Error Nginx ต้องถูกตั้งค่าให้โยน Path ที่ไม่รู้จักกลับไปหา `index.html` เสมอ
|
||||
```nginx
|
||||
location / {
|
||||
root /usr/share/nginx/html/irelaxaroma.shop/website;
|
||||
root /usr/share/nginx/html/homaroma.shop/website;
|
||||
index index.html;
|
||||
try_files $uri $uri/ /index.html; # <--- บังคับให้ SPA จัดการ Route เอง
|
||||
}
|
||||
@@ -61,11 +61,11 @@
|
||||
- **คำสั่ง Build:** `cd apps/ssr && bun run build`
|
||||
- **สิ่งที่ได้จากการ Build:** โฟลเดอร์ `.next/` และไฟล์ Source Code
|
||||
- **ตำแหน่งไฟล์ปลายทาง (Target Directory):**
|
||||
`/home/ti/projects/irelax-ssr`
|
||||
`/home/ti/projects/homaroma-ssr`
|
||||
- **การจัดการ Service (PM2):**
|
||||
ต้องสั่งรันให้แอปทำงานอยู่เบื้องหลังเสมอด้วยคำสั่ง:
|
||||
```bash
|
||||
pm2 start /home/ti/projects/irelax-ssr/node_modules/.bin/next --name irelax-ssr -- start -p 3001
|
||||
pm2 start /home/ti/projects/homaroma-ssr/node_modules/.bin/next --name homaroma-ssr -- start -p 3001
|
||||
```
|
||||
- **การตั้งค่า Nginx ที่จำเป็น (Reverse Proxy):**
|
||||
Nginx จะไม่ได้เสิร์ฟไฟล์ตรงๆ เหมือน SPA แต่ทำหน้าที่เป็นประตูส่ง Request ต่อไปให้ PM2 (ที่พอร์ต 3001)
|
||||
|
||||
Reference in new issue
Block a user