[Linux]리눅스 명령어 모음집


React를 배포하는 다양한 방법들이 있지만 이번엔 S3를 통해 배포하는 과정을 알아보도록 하겠습니다.

우선 CRA를 통해 프로젝트를 만들어줍니다.

$ create-react-app react-deploy

그 후에 yarn build를 입력하여 빌드해줍니다.

$ cd react-deploy
$ yarn build

yarn run v1.17.3
warning ../package.json: No license field
$ react-scripts build
Creating an optimized production build...
Browserslist: caniuse-lite is outdated. Please run next command `yarn upgrade`
Compiled successfully.

File sizes after gzip:

  41.2 KB  build/static/js/2.d9361fa1.chunk.js
  1.4 KB   build/static/js/3.8ca54252.chunk.js
  1.17 KB  build/static/js/runtime-main.e0cd9aa2.js
  595 B    build/static/js/main.18a981d4.chunk.js
  556 B    build/static/css/main.a617e044.chunk.css

The project was built assuming it is hosted at /.
You can control this with the homepage field in your package.json.

The build folder is ready to be deployed.
You may serve it with a static server:

  yarn global add serve
  serve -s build

Find out more about deployment here:

  https://cra.link/deployment

✨  Done in 10.49s.

build가 완료되면 다음과 같이 build 폴더가 생성됩니다.

이제 배포를 위해 S3로 넘어가줍니다.


S3 버킷 생성하기

버킷 이름을 입력하고, 모든 퍼블릭 엑세스 차단을 풀어줍니다. 그 후 생성을 눌러 버킷을 생성합니다.

그 후에 속성 탭으로 이동한 뒤,

하단에 있는 정적 웹사이트 호스팅 의 편집 을 눌러줍니다.

그 후 정적 웹 호스팅을 활성화 시키고, 인덱스 문서 및 오류 문서에 index.html을 적어주고 변경 사항 저장을 눌러 저장해줍니다.

저장 후, 권한 탭으로 이동하여

버킷 정책의 편집을 눌러줍니다