Setting to create React Project

React 개발 환경 세팅

🚀 기본 환경 세팅

프로젝트 폴더 생성

mkdir [proeject name]
cd [proeject name]

npm global 설치

npm install -g npm

node version 세팅

node --version > .node-version

npm 초기화

npm init -y

🚀 Typescript 설치 및 설정

npm i -D typescript

Typescript 설정 파일 생성

tsconfig.json 파일에서 jsx 항목 수정


🚀 ESLint 설치 및 설정

Airbnb 스타일 적용하기(optional)

TypeScript에서 Airbnb 지원하지 않기 때문에, 기존에 설치한 XO를 삭제하고 Airbnb 스타일을 적용한다.

.eslintrc.js 파일 수정

prettier 충돌 방지(optional)

.eslintrc.js 파일 수정

.eslintignore 파일 생성


🚀 React 설치

src 폴더 생성

App.tsx 파일 생성: ./src/App.tsx

main.tsx 파일 생성: ./src/main.tsx

index.html 파일 생성: ./index.html


🚀 Parcel 설치 및 설정

parcel-reporter-static-files-copy 설치

.parcelrc 생성: ./.parcelrc

static folder 생성: ./static

  • 프로젝트 root path 에 static 폴더 생성

  • 정적 이미지 등 저장 폴더


package.json 수정

main 삭제 후 아래의 코드 추가

scripts 속성 수정(*jest는 추후 설치)


🚀 프로젝트 구동 테스트


🚀 Jest 와 React Testing Library 설치

jest.config.js: ./jest.config.js

jest.setup.js 파일 생성: ./src/jest.setup.js

  • 일단 생성만 해두고, 나중에 필요할 때 코드 추가

eslintrc.js 파일 수정

테스트 구동 테스트

Last updated