| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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 | 29 | 30 | 31 |
- 인생이재밌다
- 영화예매
- 예매로직
- ajax
- node.js
- spring
- Bootstrap
- jsp
- mongodb
- post
- sessionStorage
- ssh
- mysql
- AWS Route53
- Java
- topologySpreadConstraints
- git
- AWS RDS
- MySQL Error
- javascript
- Kubernetes
- zombie-hit apartment
- terminationGracePeriodSeconds
- spread operator
- ES6
- json
- chartjs
- Get
- AWS
- html
- Today
- Total
jongviet
Feb 13, 2022 - nestJS 프로젝트 hot reload 세팅 본문
*2월13일
-express 프로젝트의 nodemon과 같은 역할을 하는 hot reload. 아래 nest.js 공식 문서 링크에 아주 잘 나와 있다.
https://docs.nestjs.com/recipes/hot-reload
Documentation | NestJS - A progressive Node.js framework
Nest is a framework for building efficient, scalable Node.js server-side applications. It uses progressive JavaScript, is built with TypeScript and combines elements of OOP (Object Oriented Progamming), FP (Functional Programming), and FRP (Functional Reac
docs.nestjs.com
-간단하게 처리하는 방법을 나열해보자면,
1.
$ npm i --save-dev webpack-node-externals run-script-webpack-plugin webpack // or yarn add
2.
root directory에 webpack-hmr.config.js 생성 후
const nodeExternals = require('webpack-node-externals');
const { RunScriptWebpackPlugin } = require('run-script-webpack-plugin');
module.exports = function (options, webpack) {
return {
...options,
entry: ['webpack/hot/poll?100', options.entry],
externals: [
nodeExternals({
allowlist: ['webpack/hot/poll?100'],
}),
],
plugins: [
...options.plugins,
new webpack.HotModuleReplacementPlugin(),
new webpack.WatchIgnorePlugin({
paths: [/\.js$/, /\.d\.ts$/],
}),
new RunScriptWebpackPlugin({ name: options.output.filename }),
],
};
};
3.
main.ts에 하단 코드들 추가
declare const module: any;
if (module.hot) {
module.hot.accept();
module.hot.dispose(() => app.close());
}
4.
package.json script에 "start:dev": "nest build --webpack --webpackPath webpack-hmr.config.js --watch"로 변경 후
npm run start:dev or yarn run start:dev
5.
프로젝트 수정 사항 감지 시, 하기와 같이 hot-module replacement가 잘 작동하는 모습이다.

'node, express, nestjs' 카테고리의 다른 글
| May 11, 2022 - Postgresql, PM2 (0) | 2022.05.11 |
|---|---|
| Feb 10, 2021 - nestjs 포인트들2 (0) | 2022.02.10 |
| Jan 31, 2021 - nestJS 포인트들 (0) | 2022.02.01 |
| Jan 25, 2021 - Nestjs관련 유튜브 강의 (0) | 2022.01.25 |
| Aug 29, 2021 - DDD pattern (0) | 2021.08.29 |