Discord-Bot-TypeScript-Template icon indicating copy to clipboard operation
Discord-Bot-TypeScript-Template copied to clipboard

Can we have hot reload?

Open Dizotoff opened this issue 2 years ago • 3 comments

Hi.

First of all, thanks a lot for this template. It's excellent to have it.

Would it be possible to add a hot reload to it? Would be great if its re-build and re-started automatically.

I tried few implementations, but they wouldn't work:

"dev:hot0": "nodemon --watch src --exec \"npm run dev\"",

"dev:hot1": "concurrently \"npm run build\" \"nodemon --watch src dist/start-bot.js\"",

Both of them stuck after change event triggered. Any ideas what might be wrong?

Dizotoff avatar Dec 28 '22 18:12 Dizotoff

Hi,

Dependencies:

yarn add -D nodemon ts-node tsc-watch

package.json:

{
  "scripts": {
    "dev": "tsc-watch --onSuccess \"yarn watch\"",
    "dev:manager": "tsc-watch --onSuccess \"yarn watch:manager\"",
    "watch": "nodemon --watch './**/*.{ts}' --exec ts-node src/start-bot.ts",
    "watch:manager": "nodemon --watch './**/*.{ts}' --exec ts-node src/manager-bot.ts"
  }
}

tsconfig.json

{
  "compilerOptions": { .... },
  "ts-node": {
    "esm": true
  }
}

matheus-caldeira avatar Jan 04 '23 00:01 matheus-caldeira

Thanks a lot @matheus-caldeira

Dizotoff avatar Jan 07 '23 10:01 Dizotoff

I like using PM2 so I just added "watch" to the process.json file

"watch": ["dist/"]

michael-delle avatar Jun 17 '23 22:06 michael-delle