3

I have a React application created using create-react-app. I also have an external application that is using this application by including the bundled JS and CSS files (the ones create using the build script).

Right now, I'm using the React template created by the dotnet new command, and I have configured the server to serve static files located in the build folder.

For this reason, I have created a couple of additional NPM scripts that rename the bundle files (remove the hash from the name), so that I don't need to update my external application's links with every build.

Right now, whenever I change something in the code, the whole build process has to be processed to create the two files.

I have created a "watch" task to run my build scripts whenever I have a change, but I was wondering if there is a way to speed up the process and somehow configure the React application to be served from memory or something just like when we "normally" run the application.

So, maybe a couple of questions:

  1. How to achieve this in a "normal" React app created by create-react-app?
  2. how to achieve this in the context of the dotnet template?
Roy Scheffers
  • 3,832
  • 11
  • 31
  • 36
Farzad
  • 1,770
  • 4
  • 26
  • 48

2 Answers2

0

you can use nodemon in the build folder of the create react app.

as the documentation says

By default nodemon monitors the current working directory. If you want to take control of that option, use the --watch option to add specific paths:

so you can use something like this:

nodemon --watch app --watch libs app/server.js

for details try other approaches given here

suraj
  • 581
  • 7
  • 17
0

This could be due to your filesystem, file extensions or the Create-React-App default webpack/project configuration. You don't necessarily have to change all of this because hot-reloading is supposed to work out of the box, and more so if the project has just started.

For example, I once had an issue with a Typescript installation(^17.0.1) where some files with extension .ts will not trigger hot reloading. I had to change to .tsx and add a React import. The same could happen with .js and .jsx files.

In case of problems with your filesystem (Unix, Mac) you can try the React config (FAST_REFRESH=false) here... or changing folder names, but I haven't bumped much into this.

Eduard
  • 311
  • 1
  • 4