I want to debug the "webpack.config.js" file, not the application using "devtool: 'source-map'". I want the webpack configuration file to be debugged. Is there any option?
1 Answer
Simply run webpack.js in debug mode using nodejs. You can run the following on your terminal (assuming you are already in the directory with your node_modules present):
node --inspect node_modules/webpack/bin/webpack.js --colors
I also found the VSCode debugger very intuitive for debugging when I was developing my own webpack loader. If you use VS Code you can have your launch.json have the following configuration:
{
"type": "node",
"request": "attach",
"name": "Attach",
"port": 5858
}
Then run the node-inspector with the following command:
node --inspect-brk=5858 node_modules/webpack/bin/webpack.js --colors
Finally, run the debug configuration by going to the debug tab, pick your configuration at the top, and then press the run configuration button.
console.log.