npm i --save-dev webpack-node-externals run-script-webpack-plugin webpack
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,
autoRestart: false,
}),
],
};
};
declare const module: any; // hot reload 관련 추가 코드
import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
import { ValidationPipe } from '@nestjs/common';
async function bootstrap() {
const app = await NestFactory.create(AppModule);
...
// hot reload 관련 추가 코드
if (module.hot) {
module.hot.accept();
module.hot.dispose(() => app.close());
}
}
bootstrap();
"start:dev": "nest build --webpack --webpackPath webpack-hmr.config.js --watch",
npm run start:dev
참고 사이트: https://docs.nestjs.com/recipes/hot-reload#installation
근데 이러면 swagger 설정 잘 되나요?
핫리로드 자체는 잘 되는데 swagger 404 not found 뜨지 않나요