Deploy React App บน GitHub Page
ติดตั้ง gh-pages npm package ด้วยคำสั่ง npm install gh-pages เพิ่ม homepage property ในไฟล์ package.json "homepage": "https://<username>.github.io/<repository-name>" เพิ่ม predeploy และ deploy ใน script ของไฟล์ package.json "predeploy": "npm run build", "deploy": "gh-pages -d build" Add remote repository ด้วยคำสั่ง git remote add origin https://github.com/<username>/<repository-name>.git Push React app ด้วยคำสั่ง npm run deploy หรือ npm run deploy -- -m "<commit-message>" npm จะทำการ build ไฟล์เก็บไว้ในโฟลเดอร์ build แล้ว deploy ขึ้นไปที่ gh-pages branch หากต้องการเก็บ React app source code ไว้บน GitHub สามารถใช้คำสั่ง git add . git commit -m "<commit-message>" git push origin main React app source code จะถูกเก็บใน main branch build file จะถูกเก็บใน gh-pages branch แหล่งอ้างอิง https://github.com/gitname/react-gh-pages