Our great sponsors
-
SurveyJS
Open-Source JSON Form Builder to Create Dynamic Forms Right in Your App. With SurveyJS form UI libraries, you can build and style forms in a fully-integrated drag & drop form builder, render them in your JS app, and store form submission data in any backend, inc. PHP, ASP.NET Core, and Node.js.
-
WorkOS
The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.
Here's what I found testing out my app locally (Git repo here). First note that my Express app is installed in the root folder of the project, and it is its own Node project (e.g. has its own package.json file, etc). My React app is installed in a sub-folder (client), and it is its own separate Node project.
Are you using webpack? If so, they have a middleware for exactly this case: https://github.com/webpack/webpack-dev-middleware. The example there should be added to your express script with some form of conditional statement to use express.static in your deployment and webpack-dev-middleware in dev.
Lastly if you want to run your dev build tool and backend as a single command you could try something like pm2 (https://www.npmjs.com/package/pm2) or concurrently (https://www.npmjs.com/package/concurrently). This isn't necessary but might be a nice-to-have. NPM workspaces could help you organize this with a common package.json file too. (https://docs.npmjs.com/cli/v7/using-npm/workspaces)
Lastly if you want to run your dev build tool and backend as a single command you could try something like pm2 (https://www.npmjs.com/package/pm2) or concurrently (https://www.npmjs.com/package/concurrently). This isn't necessary but might be a nice-to-have. NPM workspaces could help you organize this with a common package.json file too. (https://docs.npmjs.com/cli/v7/using-npm/workspaces)
See this example and use the dev_faster... run script. It uses a dev/production switch to see if it should run the devserver or host the pre-build static files as you see when you look at server.ts