๐Ÿถ๐Ÿพ/frontend

[react] Firebase๋กœ ํ”„๋กœ์ ํŠธ ๋ฐฐํฌ

onieyh 2024. 1. 26. 21:07

https://firebase.google.com/?hl=ko

 

Firebase | Google’s Mobile and Web App Development Platform

๊ฐœ๋ฐœ์ž๊ฐ€ ์‚ฌ์šฉ์ž๊ฐ€ ์ข‹์•„ํ•  ๋งŒํ•œ ์•ฑ๊ณผ ๊ฒŒ์ž„์„ ๋นŒ๋“œํ•˜๋„๋ก ์ง€์›ํ•˜๋Š” Google์˜ ๋ชจ๋ฐ”์ผ ๋ฐ ์›น ์•ฑ ๊ฐœ๋ฐœ ํ”Œ๋žซํผ์ธ Firebase์— ๋Œ€ํ•ด ์•Œ์•„๋ณด์„ธ์š”.

firebase.google.com

 

ํ”„๋กœ์ ํŠธ ์ƒ์„ฑ ํ›„ ์˜† ์นดํ…Œ๊ณ ๋ฆฌ์—์„œ ๋นŒ๋“œ > ํ˜ธ์ŠคํŒ… ํด๋ฆญ 

 

 

 

1. Firebase CLI ์„ค์น˜ 

$ npm install -g firebase-tools

 

ํ„ฐ๋ฏธ๋„์—์„œ ์‹คํ–‰ 

 

2. ํ”„๋กœ์ ํŠธ ์ดˆ๊ธฐํ™” 

$ firebase login
$ firebase init

 

vscode์—์„œ ์‹คํ–‰ (ํ„ฐ๋ฏธ๋„์—์„œ ์‹คํ–‰์‹œ rootํด๋”๊นŒ์ง€ ๊ฐ€์„œ ์‹คํ–‰)

 

firebase init (๋ฐ˜๋“œ์‹œ root ํด๋”์—์„œ ์‹คํ–‰)

๋ฐฉํ–ฅํ‚ค๋กœ ์ด๋™, hosting ์„ ํƒ(space) ํ›„ enter > Use an existing project >

? What do you want to use as your public directory? build
? Configure as a single-page app (rewrite all urls to /index.html)? Yes

...

 

.firebaserc

firebase.json 

์ƒ์„ฑ ์™„๋ฃŒ ! 

 

3. Firebase ํ˜ธ์ŠคํŒ…์— ๋ฐฐํฌ

 

์ฝ˜์†”๋กœ ์ด๋™ > hosting ํŽ˜์ด์ง€์—์„œ 'firebase ํ˜ธ์ŠคํŒ…์˜ ์—ฌ๋Ÿฌ ์‚ฌ์ดํŠธ ์ง€์›'์— ๋‹ค๋ฅธ ์‚ฌ์ดํŠธ ์ถ”๊ฐ€

๋ฐฐํฌํ•˜๊ฒŒ ๋  ์›น์‚ฌ์ดํŠธ ๋„๋ฉ”์ธ ์ถ”๊ฐ€

 

firebase.json 

{
  "hosting": {
    "site": "emotion-react-proj",
    "public": "build",
    "ignore": ["firebase.json", "**/.*", "**/node_modules/**"],
    "rewrites": [
      {
        "source": "**",
        "destination": "/index.html"
      }
    ]
  }
}

 

 "site": "๋„๋ฉ”์ธ ๋„ค์ž„" ์ถ”๊ฐ€ > ๋‹ค์‹œ ๋นŒ๋“œ

$ firebase deploy

 

๐Ÿš€ ๋ฐฐํฌ ์™„๋ฃŒ ! 

๋ฐ˜์‘ํ˜•