Firebase

1. Firebase App 만들기

2. 프로젝트에 연동하기

공식 사이트

webpack_require(…).config is not a function

https://github.com/webpack-contrib/css-loader/issues/447

tsconfig.json

{
  "compilerOptions": {
    "outDir": "./dist/",
    "sourceMap": true,
    "noImplicitAny": true,
    "module": "es6",
    "target": "es5",
    "jsx": "react",
    "allowSyntheticDefaultImports": true
  },
  "exclude": ["node_modules"]
}

webpack.config.js

module.exports = {
  entry: ["./src/index.tsx"],
  module: {
    rules: [
      {
        test: /\.tsx?$/,
        use: "ts-loader",
        exclude: /node_modules/
      }
    ]
  },
  resolve: {
    extensions: [".tsx", ".ts", ".js"]
  },
  output: {
    path: __dirname + "/dist",
    publicPath: "/",
    filename: "bundle.js"
  },
  devServer: {
    contentBase: "./dist"
  },
  node: {
    fs: "empty",
    child_process: "empty",
    net: "empty",
    tls: "empty"
  }
};

FirebaseService.tsx

var firebase = require("firebase/app");
import "firebase/firestore";

const firebaseConfig = {

};

// Initialize Firebase
firebase.initializeApp(firebaseConfig);

const firestore = firebase.firestore();

export { firestore };