Do I need to run "npm run build" every time I made changes?
Use this command:
tsc src/index.ts --watch --outDir ./lib
ref: https://www.youtube.com/watch?v=F6aHIh5NglQ
So finally, I have found my solution. When you want to re-run "npm run build" every time a file changes. You need to install watch via npm. It checks all the files inside a directory and when you change something or on-save, it will re-run all the scripts inside package.json. So steps -
- Install watch by "npm install watch"
- When watch is installed, add "watch": "watch 'npm run build' ./directory-you-want-to-track"
- Run "npm run watch"