How to use VS Code debugger with webpack-dev-server (breakpoints ignored)

后端 未结 4 1051
花落未央
花落未央 2021-01-31 03:03

My problem is simple.

I just want to make VS Code\'s debugger work with webpack-dev-server without ignoring my breakpoints.

Now, webpack-dev-server serves the bund

4条回答
  •  悲哀的现实
    2021-01-31 03:35

    For Webpack 4:
    Install webpack-cli locally if you don't already have it installed (it has been pulled out of webpack).

    Add the following VSCode debug configuration to your .vscode/launch.json (that's the file that VSCode opens when you click on the wheel icon in Debug view):

    {
      "type": "node",
      "request": "launch",
      "name": "build",
      "program": "${workspaceFolder}/node_modules/.bin/webpack-cli",
      "args": [
        "--config",
        "webpack.config.prod.js"
      ],
      "autoAttachChildProcesses": true,
      "stopOnEntry": true
    }
    

    stopOnEntry will make debugger stop in the very first (shebang) line of webpack.js, like this:

提交回复
热议问题