0

I am trying to setup VS Code + Vue.js to work on some Vue.js project. I already did some steps, but I cannot make breakpoints work correctly.

if I start the website with

npm run dev

And then start debugging in VS Code with Debugger for Chrome and set a breakpoint on a certain line of code in a .vue file, the line is normally marked with the red circle, but the breakpoint is triggered in different app.js file in the code like this:

// module
exports.push([module.i...
// exports
/***/ }),

what can be wrong with my debugger settings?

my config:

{
"version": "0.2.0",
"configurations": [
  {
    "type": "chrome",
    "request": "launch",
    "name": "Launch Chrome against localhost",
    "url": "http://localhost:8080",
    "webRoot": "${workspaceRoot}"
  },
  {
    "type": "chrome",
    "request": "attach",
    "name": "Attach to Chrome",
    "port": 9222,
    "webRoot": "${workspaceRoot}"
  }
]
}

devtool: 'source-map',

my vue-cli version is [email protected].

2 Answers 2

1

Check the Vue.js cookbook:

Showing Source Code

In config/index.js, add:

devtool: 'source-map',

and

Launching the Application

Your launch.config should look like this:

"configurations": [
{
  "type": "chrome",
  "request": "launch",
  "name": "vuejs: chrome",
  "url": "http://localhost:8080",
  "webRoot": "${workspaceFolder}/src",
  "breakOnLoad": true,
  "sourceMapPathOverrides": {
    "webpack:///src/*": "${webRoot}/*"
  }
}
Sign up to request clarification or add additional context in comments.

Comments

1

I've had problems with Feetball's solution from Vue.js Cookbook - it was clear to me it wasn't working correctly because breakpoints would be triggered in wrong places and the debugger would open incorrect files.

I've had better results with this debug configuration from the Microsoft vscode-recipes repository:

The link above has detailed instructions but I'll just paste the launch config. The instructions are the same as in Vue.js cookbook

launch.json:

{
  "version": "0.2.0",
  "configurations": [
    {
      "type": "chrome",
      "request": "launch",
      "name": "vuejs: chrome",
      "url": "http://localhost:8080",
      "webRoot": "${workspaceFolder}/src",
      "breakOnLoad": true,
      "sourceMapPathOverrides": {
        "webpack:///./src/*": "${webRoot}/*",
        "webpack:///src/*": "${webRoot}/*",
        "webpack:///*": "*",
        "webpack:///./~/*": "${webRoot}/node_modules/*"
      }
    }
  ]
}

And here's the result of it working in a computed property (also works in mounted etc.):

enter image description here

Comments

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.