38

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
  • 1
    Same as any other nodejs application. Or simply console.log. Commented Dec 30, 2016 at 13:22

1 Answer 1

38

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.

Sign up to request clarification or add additional context in comments.

2 Comments

Wonderful solution, it helped me to debug my Webpack.config file
You can point it to the webpack.config.js file, if that's needed: node --inspect-brk=9229 ./node_modules/webpack/bin/webpack.js --config webpack.config.js --colors

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.