JavaScript/TypeScript
TypeScript
kimddakki
2022. 6. 10. 17:35
tsc-watch 사용이유
- ts 코드가 바뀔 때마다 js로 컴파일 한 뒤 node를 실행하는 과정을 반복했지만
ts-watch를 사용하면 그러지 않아도 된다.
=> TypeScript 버전 nodemon인 셈!
1. tsc-watch 설치
yarn add tsc-watch
2. root 폴터와 dist 폴더 생성
- dist 폴더는 컴파일 된 JavaScript 파일들이 모인다.
- root 폴더는 컴파일 될 TypeScript가 모여있는 곳이다.
3. tsconfig.json 파일 수정!
outDir : "dist" - 컴파일 된 JavaScript 파일이 모일 경로
include : ["root"/**/*"] - TypeScript 파일들이 모여있는 경로
4. pacage.json 파일 수정
"start" : "tsc-watch --onSuccess \" node dist/index.js \" "
"start" : "tsc-watch --onSuccess(컴파일이 성공했을 때) \" 이 명령어를 실행해라 \" "
5. yarn start
TypeScript tsc-watch 사용하기
* 아래의 글은 JavaScript 프롤로그 및 목차를 먼저 읽으신 후 읽으시기를 권장합니다. * tsc-watch 사용은 TypeScript 타입스크립트 기본세팅 방법을 따라하신 후 사용하기를 권장합니다. 본 글에서 다룰
bigstar-vlog.tistory.com