react app github page ๋ฐฐํฌ

๋ฆฌ๋ฆฐยท2021๋…„ 8์›” 19์ผ
0

React

๋ชฉ๋ก ๋ณด๊ธฐ
13/47

https://velog.io/@byjihye/react-github-pages

๐ŸŒ React ํ”„๋กœ์ ํŠธ GitHub Pages ๋ฐฐํฌํ•˜๊ธฐ

์ €๋Š” ํ”„๋กœ์ ํŠธ create-react-app ์œผ๋กœ ๋งŒ๋“ค์—ˆ์Šต๋‹ˆ๋‹ค :)

๐Ÿ‘€ 1. GitHub ์ €์žฅ์†Œ ๋งŒ๋“ค๊ธฐ
๋จผ์ € ์ž์‹ ์˜ github์— ์ €์žฅ์†Œ๋ฅผ ํ•˜๋‚˜ ์ƒ์„ฑํ•ด์ค๋‹ˆ๋‹ค.
์ €๋Š” react-github-pages๋กœ ๋งŒ๋“ค์—ˆ์Šต๋‹ˆ๋‹ค :)

์ €์žฅ์†Œ์ด๋ฆ„, ์„ค๋ช… ์ž‘์„ฑํ•˜๊ณ  Create repository ํด๋ฆญ

๐Ÿ‘€ 2. ํ”„๋กœ์ ํŠธ์—์„œ git ์ €์žฅ์†Œ ์„ค์น˜ํ•˜๊ธฐ

์ฐจ๋ก€๋Œ€๋กœ ๋ช…๋ น์–ด ์‹คํ–‰

git init
git add *
git commit -m 'first commit'
git remote add origin https://github.com/JIHYE-P/react-github-pages.git
git push -u origin master
๋ช…๋ น์–ด์— ๋Œ€ํ•ด์„œ ๊ฐ„๋‹จํžˆ ์„ค๋ช…์„ ๋ง๋ถ™ํžˆ์ž๋ฉด,,,

git init - ํ”„๋กœ์ ํŠธ์— git์„ค์น˜
git add * - .gitignore์— ์žˆ๋Š” ํŒŒ์ผ ์ œ์™ธํ•˜๊ณ  ๋ชจ๋‘ ์˜ฌ๋ฆฌ๊ธฐ
git commit -m 'first commit' - commit ๋ฉ”์„ธ์ง€ ์ž‘์„ฑ
git remote add origin https://github.com/JIHYE-P/react-github-pages.git - git ์ €์žฅ์†Œ ์—ฐ๊ฒฐ
git push -u origin master - git master๋กœ push

push๊นŒ์ง€ ์™„๋ฃŒ๋˜๋ฉด github ํŽ˜์ด์ง€๋กœ ๋Œ์•„๊ฐ€์„œ ์ƒˆ๋กœ๊ณ ์นจํ•˜๋ฉด ์†Œ์Šค๋“ค์ด ์˜ฌ๋ผ์™€์žˆ๋‹ค.

๐Ÿ‘€ 3. github pages ๋ฐฐํฌํ•˜๊ธฐ
๋จผ์ € ํ”„๋กœ์ ํŠธ์— gh-pages ํŒจํ‚ค์ง€๋ฅผ ์„ค์น˜ํ•ด์•ผํ•ฉ๋‹ˆ๋‹ค.

npm install gh-pages --save-dev
์„ค์น˜๊ฐ€ ์™„๋ฃŒ๋˜๋ฉด ํ”„๋กœ์ ํŠธ์— ์žˆ๋Š” package.json ํŒŒ์ผ์„ ์—ด์–ด "homepage" ์ฃผ์†Œ๋ฅผ ์ถ”๊ฐ€ํ•ฉ๋‹ˆ๋‹ค.

//....
"homepage": "http://JIHYE-P.github.io/react-github-pages"
ํ˜•์‹์€ http://{์‚ฌ์šฉ์ž ์ด๋ฆ„}.github.io/{์ €์žฅ์†Œ ์ด๋ฆ„}๋กœ ์ž‘์„ฑํ•ฉ๋‹ˆ๋‹ค.

๊ทธ๋‹ค์Œ, script ๋ถ€๋ถ„์— predeploy, deploy ๋ฅผ ์ถ”๊ฐ€ํ•ฉ๋‹ˆ๋‹ค.

"scripts": {
//...
"predeploy": "npm run build",
"deploy": "gh-pages -d build"
}
์ €์žฅํ•˜๊ณ  ํ„ฐ๋ฏธ๋„์ฐฝ์„ ์—ด์–ด npm run deploy๋ฅผ ์‹คํ–‰ํ•ฉ๋‹ˆ๋‹ค.

ํ™•์ธ์„ ์œ„ํ•ด github ํ•ด๋‹น ์ €์žฅ์†Œ ํŽ˜์ด์ง€๋กœ ๋Œ์•„๊ฐ€ ์šฐ์ธก์— ์žˆ๋Š” Settings -> Options ์—์„œ GitHub Pages ์—์„œ ํ™•์ธํ•˜์‹ค ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
(๋งŒ์•ฝ ์‚ฌ์ดํŠธ์—์„œ README.md ํŒŒ์ผ ๋‚ด์šฉ์ด ๋‚˜์˜ฌ ๊ฒฝ์šฐ GitHub Pages์˜
Source ๋ถ€๋ถ„์—์„œ gh-pages branch๋กœ ๋ณ€๊ฒฝํ•˜๋ฉด ์‚ฌ์ดํŠธ๊ฐ€ ์ •์ƒ์ ์œผ๋กœ ๋ฐฐํฌ๋ฉ๋‹ˆ๋‹ค!!)

๋ฐฐํฌ์™„๋ฃŒ! ๐Ÿ‘

๐Ÿ‘€ 4. ์ฐธ๊ณ  (2021.01.14)
๋‹ค๋ฅธ ํ”„๋กœ์ ํŠธ๋ฅผ ๋ฐฐํฌํ•˜๋Š” ๊ณผ์ •์—์„œ
hompage : "http://{์‚ฌ์šฉ์ž ์ด๋ฆ„}.github.io/{์ €์žฅ์†Œ ์ด๋ฆ„}" ๋กœ ์„ค์ •๋œ ์ฃผ์†Œ๋กœ ์ ‘์†ํ•˜๋‹ˆ๊นŒ 404 ํŽ˜์ด์ง€๊ฐ€ ๋‚˜์™”๋‹ค.
์ด๋Ÿด๋•Œ http://{์‚ฌ์šฉ์ž ์ด๋ฆ„}.github.io/{์ €์žฅ์†Œ ์ด๋ฆ„}/index.html ๋กœ ์ ‘์†ํ•˜๋ฉด ๋‚˜์˜จ๋‹ค.

profile
๊ฐœ๋ฐœ์ž์ง€๋ง์ƒ

0๊ฐœ์˜ ๋Œ“๊ธ€