You can super charge your React debugging workflow via VS Code and Chrome. Here are the steps:
- Install the Debugger for Chrome extension in VS Code.
- Add the
Launch Chrome
option to yourlaunch.json
config:
{
"version": "0.2.0",
"configurations": [
{
"type": "chrome",
"request": "launch",
"name": "Launch Chrome",
"url": "http://localhost:3000",
"webRoot": "${workspaceRoot}/app",
"sourceMapPathOverrides": {
"webpack:///./app/*": "${webRoot}/*",
"webpack:///app/*": "${webRoot}/*"
}
}
]
}
- Start your dev server with
npm run start
. - Launch the VS Code Debugger with the
Launch Chrome
configuration.
You can then set breakpoints directly from inside VS Code, use stepping with the Chrome or VS Code buttons and more.
Read all about it in the Debugger for Chrome page.
Note: There's currently a known problem with source maps and VS Code. You can change your Webpack dev config to use inline-source-map
instead of eval-source-map
and the issue should be resolved.
WebStorm is a powerful IDE, and why not also use it as debugger tool? Here are the steps:
- Install JetBrain Chrome Extension
- Setting up the PORT
- Change WebPack devtool config to
source-map
(This line) - Run web server (
npm run start
) - Create Run Configuration (Run > Edit Configurations)
- Add new
JavaScript Debug
- Setting up URL
- Start Debug (Click the green bug button)
- Edit Run Configuration Again
- Mapping Url as below picture
- Map your
root
directory withwebpack://.
(please note the last dot) - Map your
build
directory with your root path (e.g.http://localhost:3000
)
- Map your
- Hit OK and restart debugging session
- You miss the last
.
(dot) inwebpack://.
- The port debugger is listening tool and the JetBrain extension is mismatch.
ESLint helps developers on a team follow the same coding format. It's highly recommended to set it up in your IDE to avoid failing the linting step in tests.
- Go to WebStorm Preferences
- Search for
ESLint
- Click
Enable