티스토리 뷰
1. Procfile 만들기 타입스크립트면 ts , 일반이면 js
//Procfile
web: node server.js
2. server 파일 만들기
//server.js
const jsonServer = require("json-server");
const server = jsonServer.create();
const router = jsonServer.router("./db.json");
const middlewares = jsonServer.defaults({
static: "./build",
});
const port = process.env.PORT || 4000;
server.use(middlewares);
server.use(
jsonServer.rewriter({
"/api/*": "/$1",
})
);
server.use(router);
server.listen(port, () => {
console.log("server is running");
});
3. package.json 파일에 script 추가하기
"scripts": {
"start": "node server",
"start:dev": "cross-env NODE_PATH=src react-scripts start",
"build": "cross-env NODE_PATH=src react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject",
"heroku-postbuild": "cross-env NODE_PATH=src npm run build"
},
npm i cross-env
설치해야 작동함
https://www.npmjs.com/package/cross-env
cross-env
Run scripts that set and use environment variables across platforms. Latest version: 7.0.3, last published: a year ago. Start using cross-env in your project by running `npm i cross-env`. There are 4820 other projects in the npm registry using cross-env.
www.npmjs.com
4. Heroku CLI 설치
https://devcenter.heroku.com/articles/heroku-cli
The Heroku CLI | Heroku Dev Center
Last updated February 01, 2022 The Heroku Command Line Interface (CLI) lets you create and manage Heroku apps directly from the terminal. It’s an essential part of using Heroku. Install the Heroku CLI Pre-requisites The Heroku CLI requires Git, the popul
devcenter.heroku.com
wsl2 유저는 이것 설치
curl https://cli-assets.heroku.com/install.sh | sh
버전확인 heroku -v
5.본인 프로젝트 마스터 브런치 혹은 default 브런치에서 heroku login
$ git init
$ git add .
$ git commit -am'initial commit'
그 이후
$ heroku create <프로젝트명> # 프로젝트명을 공백으로 하시면 이름이 자동으로 랜덤설정 됩니다.
$ heroku config:set NPM_CONFIG_PRODUCTION=false # devDependency 도 설치하게 설정합니다
$ git push heroku master
에러가 날 경우
heroku buildpacks:set mars/create-react-app
터미널에 입력
참고 블로그
https://bogmong.tistory.com/11
React Application을 Heroku에 Deploy하며 겪은 오류(Error H10)
헤로쿠(Heroku)는 다양한 프로그래밍 언어를 지원하는 PaaS(Platform as a Service)이다. 2007년 처음 개발되었을 때는 루비 언어만 지원했지만 현재는 Java, Node, Scala, Python, Go 등의 다양한 언어를 지원하..
bogmong.tistory.com
https://redux-advanced.vlpt.us/3/09.html
3-9. 최적화 및 히로쿠에 디플로이하기 · GitBook
3-9. 최적화 및 히로쿠에 디플로이하기 최적화 여러분이 리스트를 렌더링 했다면, 그리고 또 그 리스트가 많은 데이터를 보여주게 된다면, 최적화 작업을 진행해주셔야 프로젝트의 성능이 좋아
redux-advanced.vlpt.us
https://github.com/mars/create-react-app-buildpack
GitHub - mars/create-react-app-buildpack: ⚛️ Heroku Buildpack for create-react-app: static hosting for React.js web apps
⚛️ Heroku Buildpack for create-react-app: static hosting for React.js web apps - GitHub - mars/create-react-app-buildpack: ⚛️ Heroku Buildpack for create-react-app: static hosting for React.js web ...
github.com
https://github.com/jesperorb/json-server-heroku#deploy-to-heroku
GitHub - jesperorb/json-server-heroku: Deploy json-server to Heroku & Glitch & Azure
Deploy json-server to Heroku & Glitch & Azure :up: :free: - GitHub - jesperorb/json-server-heroku: Deploy json-server to Heroku & Glitch & Azure
github.com
https://heeyeonjeong.tistory.com/102
Heroku로 react 프로젝트 배포하기 (json-server 포함)
json-server가 프로덕션 전용이 아닌 것을 알지만, 백엔드 서버가 없기 때문에.. 프로젝트 배포 시 json-server도 같이 배포하기 위해 여러 배포 서비스를 찾아봤다. 그전에 가장 쉽게 접근 가능한 gh-pag
heeyeonjeong.tistory.com
'배포' 카테고리의 다른 글
heroku 무료 버전 폐지 ! cloudtype.io 로 웹 서버 옮기기 json-server 를 배포 (0) | 2023.01.07 |
---|---|
heroku 무료 버전 폐지 ! fly.io로 웹 서버 옮기기 (wsl2 fly.io install) (0) | 2022.12.30 |
gh-pages 로 리액트 사이트 배포하기 // gh-pages 로 SPA 지원하기 // 배포한 사이트 새로고침 가능 (0) | 2022.02.27 |
heroku 에서 배포한 사이트 30분 주기로 잠에서 깨우기 잠자는 사이트 (0) | 2022.02.19 |
AWS S3 ,CloudFront로 리액트앱 프론트앤드 웹페이지 배포하기 (0) | 2022.02.03 |
- Total
- Today
- Yesterday
- WSL2
- nextjs
- 노개북
- NextRequest
- Storybook
- 프론트앤드
- 윤성우 열혈C프로그래밍
- 스토리 북
- nodejs
- NextApiRequest
- TopLayer
- 프리온보딩
- 위코드
- 초보
- C언어
- import/order
- electron
- 우아한테크코스
- javascript
- 아차산
- error
- CLASS
- React
- createPortal
- env
- jest
- 원티드
- 노마드코더
- 북클럽
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |