2024.03.22(금)
.
└── src/
├── index.tsx # 스크립트 진입점 파일
├── App.tsx # 메인 앱 컴포넌트
├── App.css # 메인 스타일시트
├── router.tsx # 라우터 파일
├── settings.ts # 환경변수 파일
├── pages/ # 페이지 컴포넌트 모음
│ ├── Index.tsx
│ ├── Login.tsx
│ ├── Join.tsx
│ ├── Error.tsx
│ └── notes/
│ ├── Index.tsx
│ └── Detail.tsx
├── components/ # 세부 컴포넌트 모음
│ ├── LoginForm.tsx
│ ├── JoinForm.tsx
│ ├── NoteList.tsx
│ ├── NoteTitleInput.tsx
│ ├── NoteContentEditor.tsx
│ ├── boundaries/
│ │ ├── AppErrorBoundary.tsx
│ │ └── RouteErrorBoundary.tsx
│ └── hocs/
│ ├── withUnauthenticated.tsx
│ ├── withAuthenticatedUser.tsx
│ └── withCurrentNote.tsx
├── apis/ # API 호출 함수 모음
│ ├── auth.api.ts
│ └── notes.api.ts
├── hooks/ # React Query 상태관리 관련 Hook 모음
│ ├── useAuth.ts
│ └── useNotes.ts
├── types/ # 모델 타입 모음
├── utils/ # 유틸리티 함수 및 객체 모음
│ ├── https.ts
│ └── getStatusFromError.ts
└── assets/ # 아이콘 및 이미지 모음
App.test.tsx
index.css
logo.svg
reportWebVital.ts
npx create-react-app frontend --template typescript
frontend
폴더로 이동 후 craco 설치cd frontend
npm i @craco/craco
package.json
의 scripts field에서 start, build, test를 craco를 통해 할 수 있도록 수정{
…,
"scripts": {
"start": "**craco** start",
"build": "**craco** build",
"test": "**craco** test",
"eject": "react-scripts eject",
"typecheck": "tsc --noEmit --skipLibCheck"
},
…
}
npm i tsconfig-paths-webpack-plugin
tsconfig.json
의 compilerOptions field 및 exclude field 설정{
"compilerOptions": {
…,
"baseUrl": "./",
"paths": {
"@/*": ["src/*"]
}
},
…,
"exclude": ["src/**/*.test.ts", "src/**/__mocks__/*.ts"]
}
craco.config.js
파일 생성 및 다음과 같이 설정const TsconfigPathsPlugin = require("tsconfig-paths-webpack-plugin");
/** @type {import('webpack').Configuration} */
module.exports = {
plugins: [
{
plugin: {
overrideWebpackConfig: ({ webpackConfig }) => {
webpackConfig.resolve.plugins.push(new TsconfigPathsPlugin({}));
return webpackConfig;
},
},
},
],
};
npm start
npm run build && serve -s build
CI=true npm test
npm start
" 에 의하여 실행한 상태를 가정frontend/build/env.js
파일을 컨테이너 빌드 타임에 생성
프로젝트 프론트엔드 폴더: https://github.com/do0ori/web-editor-project/tree/main/frontend
처음부터 끝까지 혼자 만드니까 생각보다 어려워서 시간도 오래걸리고 힘들었다..🤯 포기하지 않고 결국 어떻게든 완성했다 하하