Answer the question
In order to leave comments, you need to log in
How to debug a bundle of Node.js backend and React frontend as a whole in WebStorm?
Given:
A project consisting of two parts:
Command: run
,Script: dev
...
"scripts": {
...
"dev": "webpack serve --mode=development --config webpackfile.js --hot"
}
...
webpack-dev-server
. On the one hand, it’s good that hot-reload is available, but on the other hand, it’s bad that all the business logic that the backend is responsible for is not available. webpack --mode=development --config webpackfile.js --watch
, which makes the initial assembly of the frontend to the desired folder, and then rebuilds if any of the frontend sources changesnodejs backend.js
, which is passed through arguments or an environment variable the path where webpack assembled the frontend in the previous stepAnswer the question
In order to leave comments, you need to log in
In general, I found an acceptable solution. Who cares:
package.json
:...
"scripts": {
...
"dev": "webpack --mode=development --config webpackfile.js --watch"
}
...
CONTENT_PATH='/../../debug'
const contentPath = path.resolve(__dirname + (process.env.CONTENT_PATH || ''));
contentPath
when accessing frontend filesYou debug the front in devtools in the browser, run the back directly from the webstorm through the debug of the nodejs script, and debug in the IDE.
If you want to do this and that in a webstorm, then the front can also be launched along with the back and debugged in the IDE and not in the browser (you start two processes for debugging in the webstorm except for one), but this is not for everyone, I don’t like it and therefore I won’t tell you a specific config . You can google.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question