Skip to content

chore: migrate frontend to Vite and modernize structure#4

Open
pyyupsk wants to merge 2 commits intothananon:mainfrom
pyyupsk:feat/vite-migration
Open

chore: migrate frontend to Vite and modernize structure#4
pyyupsk wants to merge 2 commits intothananon:mainfrom
pyyupsk:feat/vite-migration

Conversation

@pyyupsk
Copy link

@pyyupsk pyyupsk commented May 24, 2025

ปรับฝั่ง frontend จากการใช้ Create React App (CRA) มาเป็น Vite ครับ
Vite ช่วยให้เราพัฒนาได้เร็วขึ้น และดูแลง่ายขึ้นในระยะยาวครับ

สิ่งที่เปลี่ยนไปหลัก ๆ:

  • เปลี่ยนชื่อไฟล์จาก .js.jsx สำหรับ component และ hook ที่มี JSX
  • เพิ่ม eslint.config.js สำหรับจัด format โค้ดให้ consistent ขึ้น และ lint error
  • ลบไฟล์ที่ไม่ได้ใช้งาน (reportWebVitals.js)จริง ๆ แล้วมันเรียกใช้ฟังก์ชันผิดครับ (ref)

ผมอยากช่วยลดความซับซ้อนของ tooling ให้เหลือเท่าที่จำเป็นครับ
Vite เป็น build tool สมัยใหม่ที่มาแทนที่ CRA ได้เต็มตัว และดีกว่าในหลายด้านเลยครับ เช่น:

  • dev server ทำงานเร็วขึ้น
  • ลดเวลา setup สำหรับคนที่อยาก contribute โปรเจกต์นี้ในอนาคต
  • ไม่มีการเปลี่ยน logic ด้านใน ทุกอย่างยังทำงานเหมือนเดิมครับ

ผมพยายามไม่แตะ logic ข้างในครับ แค่ย้ายเครื่องมือ build ให้เบาขึ้นและง่ายขึ้นครับ

ถ้าน้าอามเห็นว่ายังไม่เหมาะสมกับตอนนี้ ผมยินดีปรับตามคำแนะนำเลยครับ
ถ้าจะปิด PR ก็ไม่มีปัญหาเลยครับ เคารพการตัดสินใจของน้าอามเต็มที่ครับผม

ขอบคุณมากครับสำหรับไอเดียดี ๆ ครับ

@thananon
Copy link
Owner

npm run start doesn't work. npm run dev works. Can you add this functionality?

@pyyupsk
Copy link
Author

pyyupsk commented May 25, 2025

npm run start will be a little slower than before because it needs to be built before running prod mode.
At root, I have it build automatically.
But if you run it yourself in frontend/, you need to npm run build before npm run start.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments