์ด๋ฒ์๋ deploy๊น์ง ํด๋ณด์!
1, 2ํธ์ ๋์ณค๋ค๋ฉด ๊ผญ ๋ณด๊ณ ์ค์!
npm i firebase
Firebase๋ฅผ ์ค์นํด์ค๋ค.
์ด์ ์๊น ์์ฑํ๋ Firebase ํ๋ก์ ํธ์์ api key๋ id ๋ฑ์ด ๋ด๊ธด config object๋ฅผ ๊ฐ์ ธ์์ผ ํ๋ค.
์ข์ธก์ ํ๋ฒ๊ฑฐ ๋ฉ๋ด๋ฅผ ๋๋ฅธ ํ ํ๋ก์ ํธ ๊ฐ์ ์์ ์ค์ ๋ฒํผ์ ํด๋ฆญํ๋ค.
ํ๋ก์ ํธ ์ค์ ์ ๋ค์ด๊ฐ๋ฉด ํ์ํ ๋ด์ฉ์ด ์๋ค.
๋ด๋ฆฌ๋ค ๋ณด๋ฉด SDK ์ค์ ๋ฐ ๊ตฌ์ฑ์ด ๋์จ๋ค. npm์ ์ ํํ๋ฉด ๋์ค๋ ๋ด์ฉ์ src/index.js
์์ ๊ทธ๋๋ก ๋ฃ์ด์ค๋ค. (ํ๋ก์ ํธ๋ง๋ค ๋ค๋ฅธ ๊ฐ์ด ๋ค์ด ์์ผ๋๊น ํ์ฌ ์งํ ์ค์ธ ํ๋ก์ ํธ์์ ๊ฐ์ ธ์ค๋ฉด ๋๋ค.)
// Import the functions you need from the SDKs you need
import { initializeApp } from "firebase/app";
// TODO: Add SDKs for Firebase products that you want to use
// https://firebase.google.com/docs/web/setup#available-libraries
// Your web app's Firebase configuration
const firebaseConfig = {
apiKey: "AIzaSyAP7b_6QFUUs5DjlePHzDP4PN1iZ-yFrPA",
authDomain: "myproject-daf20.firebaseapp.com",
projectId: "myproject-daf20",
storageBucket: "myproject-daf20.appspot.com",
messagingSenderId: "534036629128",
appId: "1:534036629128:web:51db7081a6f9f37c3d813d"
};
// Initialize Firebase
const app = initializeApp(firebaseConfig);
Firebase๋ฅผ ์ด์ฉํด ์ฌ์ดํธ์ deploy๋ฅผ ํ๊ธฐ ์ํด์๋ firebase-tools
ํจํค์ง๊ฐ ํ์ํ๋ค.
npm install firebase-tools -g
firebase login
ํ๋ก์ ํธ ํด๋์์ Firebase์ ๋ก๊ทธ์ธํด์ค๋ค. (Gitpod ๋ฑ, ๋ก์ปฌ ํธ์คํธ๋ก ์ฐ๊ฒฐ๋์ง ์๋ ํ๊ฒฝ์์๋ firebase login โno-localhost
๋ก ํ ์ ์๋ค.
๋งํฌ๋ฅผ ํ๊ณ ๋ค์ด๊ฐ๋ฉด ๋ด๊ฐ ๋ก๊ทธ์ธ ํ๋ ค๋๊ฒ ๋ง๋์ง ํ์ธํ๋ ๊ณผ์ ์ด ์๋ค.
๋ง์ผ๋๊น ๋์ด๊ฐ์ฃผ์.
Authentication Code๋ฅผ ๋ณต์ฌํ๋ค.
ํฐ๋ฏธ๋์ ์
๋ ฅํด์ฃผ๋ฉด ๋ก๊ทธ์ธ์ด ๋๋๋ค.
Firebase init
Firebase ํ๋ก์ ํธ๋ฅผ ์คํํด์ค๋ค.
๋ฐฉํฅํค๋ก ์ ํํ ์ ์๋ ํ๋ฉด์ด ๋์จ๋ค.
์คํ์ด์ค๋ฐ๋ก ์ ํํ๊ณ ์ํฐ๋ก ๋์ด๊ฐ ์ ์๋ค.
๋๋ถ๋ถ Storage๋ ํ์ํ๊ฒ ์ง๋ง, ์ผ๋จ์ ์ฌ์ดํธ์ ์ฌ๋ฆฌ๋๊ฒ ๋ชฉ์ ์ด๋ Hosting๋ง ์ ํํด์ฃผ๊ณ ๋์ด๊ฐ์.
Hosting์ด 2๊ฐ๊ฐ ์๋๋ฐ ์ ์ฌ์ง์ฒ๋ผ ์ฒซ๋ฒ์งธ๋ฅผ ์ ํํด์ฃผ๋ฉด ๋๋ค.
public ๋๋ ํ ๋ฆฌ ๋ก ์ด๋ค ํด๋๋ฅผ ์ ํํ ์ง ๋ฌผ์ด๋ณธ๋ค. ์ฐ๋ฆฌ๋ dist๋ก ๋ง๋ค์์ผ๋๊น dist๋ฅผ ์ ๋ ฅํ๋ค.
single-page app๋ก ์ค์ ํ๋๋ ์ง๋ฌธ์๋ yes, ๋๋จธ์ง๋ No๋ผ๊ณ ํด์ค๋ค.
์ด์ฏค์์ ํน์ ์ค๊ฐ์ ๊บผ์ง ์ ์ด ์๊ฑฐ๋ ํด์ webpack์ผ๋ก ํ์ฌ ์ฝ๋๋ฅผ ๋ค์ bundlingํด์ค์ผํ๋ ์ํฉ์ผ ์ ์์ผ๋ ๋ค์์ ์คํํด์ค๋ค.
npm run build
์ด์ deploy๋ง ๋จ์๋ค!
firebase deploy
Hosting URL ๋ค์ ์ฃผ์๋ก ๊ฐ๋ณด์!
์ ๋์ค๋ ๊ฑธ ๋ณผ ์ ์๋ค๐ฅ๐๐ป๐๐ป
๋ค์์๋ ์ฌ์ดํธ๋ง๋ค ํํ ๋ณผ ์ ์๋ Sign in with Google์ ๊ตฌ์ถํด๋ณด์.