ยท react
Setup Webpack HMR with NestJS and React
This article explains how to set up a NestJS server with Webpack's Hot Module Replacement (HMR) to host a React web application. It provides code examples and instructions on how to access the Express instance from the NestJS framework and how to bring Webpack and its HMR plugin to your React web application.
Programmatically setup a Nest.JS server with Webpack's Hot Module Replacement (HMR) to host a React web application.
Contents
Setup
Setting up a NestJS server with Webpack's Hot Module Replacement is as simple as setting up an Express server with Webpack's HMR. The key is to get access to the Express instance from the NestJS framework:
Here is a generic function to bring Webpack and its HMR plugin to your React web application served by an Express server:
Tested with
- @nestjs/common 7.6.3
- @nestjs/core 7.6.3
- @nestjs/platform-express 7.6.3