I've got a configuration file where in the webpack devServer config Withing the webpack devServer config, I have defined a express middleware function:
devServer: {
before(app){
init(app);
},
...
}
Where init is a function of the form:
init(app){
app.get('/endpoint', (req,res,next)=> {...;debugger; next();});
...
}
How can I debug this webpack-dev-server code?
I would prefer if I could debug it straight in VSCode, but I'm happy to use in-browser debugging if necessary.
I've got a configuration file where in the webpack devServer config Withing the webpack devServer config, I have defined a express middleware function:
devServer: {
before(app){
init(app);
},
...
}
Where init is a function of the form:
init(app){
app.get('/endpoint', (req,res,next)=> {...;debugger; next();});
...
}
How can I debug this webpack-dev-server code?
I would prefer if I could debug it straight in VSCode, but I'm happy to use in-browser debugging if necessary.
Share edited Feb 26, 2018 at 23:27 keithlee96 asked Feb 26, 2018 at 6:22 keithlee96keithlee96 1,9642 gold badges13 silver badges17 bronze badges1 Answer
Reset to default 6As it turns out, there was a pretty simple way to debug webpack-dev-server in VSCode. Just debug the executable as a node file!
Here was my launch.json
:
{
"type": "node",
"request": "launch",
"name":"launch webpack-dev-server",
"program": "${workspaceFolder}/node_modules/webpack-dev-server/bin/webpack-dev-server.js",
"args": ["--progress", "--inline", "--config", "build/webpack.dev.conf.js"]
}
Note: For anyone who copies this, you will have to change the webpack configuration file path arg to whatever it is on your machine.
You can debug webpack build scripts in the exact same way:
{
"type": "node",
"request": "launch",
"name":"launch webpack",
"program": "${workspaceFolder}/node_modules/webpack/bin/webpack.js",
"args": ["--progress", "--config", "build/webpack.prod.conf.js"]
},
Note: this debugs the build / server itself. If you want to debug the output files, you need to also attach a debugger to the url. You can do that using using something like the chrome debugger.