Optimizing VSCode and Chrome for Vue.js Debugging: A Comprehensive Guide for Backend Developers

This guide will walk you through setting up VSCode with Chrome for debugging Vue.js projects, covering source map configuration and launch settings for differant project structures.

Enabling Webpack Source Maps

First, create a vue.config.js file in your project root to enable webpack source maps:

module.exports = {
  configureWebpack: {
    devtool: 'source-map'
  }
}

Next, navigate to the Run and Debug panel in VSCode and create a launch.json configuration file. The specific settings will depend on your project's src directory location.

Project Structure: src at Root Directory

For projects with the following structure: vue-project/src

Your .vscode/launch.json should include:

  • Specify the project's development port: "url": "http://localhost:5173"
  • Define the src directory location: "webRoot": "${workspaceFolder}/src"
  • Enable source maps: "sourceMaps": true
  • Set trace to true for detailed debugging logs: "trace": true
{
  "version": "0.2.0",
  "configurations": [
    {
      "type": "chrome",
      "request": "launch",
      "name": "Launch Chrome against localhost",
      "url": "http://localhost:5173",
      "webRoot": "${workspaceFolder}/src",
      "sourceMaps": true,
      "trace": true
    }
  ]
}

To begin debugging:

  1. Start your project normally: npm run dev or npm run serve
  2. Add breakpoints to your source code at appropriate locations
  3. Click the Debug button in the VSCode sidebar to launch in debug mode
  4. A new Chrome browser window will open with debugging capabilities enabled

Project Structure: src in Nested Directory

For projects with the following structure: parent-project/module-vue/src

Your .vscode/launch.json should include:

  • Specify the project's development port: "url": "http://localhost:5173"
  • Define the src directory location: "webRoot": "${workspaceFolder}/module-vue/src"
  • Enable source maps: "sourceMaps": true
  • Set trace to true for detailed debugging logs: "trace": true
{
  "version": "0.2.0",
  "configurations": [
    {
      "type": "chrome",
      "request": "launch",
      "name": "Launch Chrome against localhost",
      "url": "http://localhost:5173",
      "webRoot": "${workspaceFolder}/module-vue/src",
      "sourceMaps": true,
      "trace": true
    }
  ]
}

The debugging process remains the same as in the previous scenario:

  1. Start your project normally: npm run dev or npm run serve
  2. Add breakpoints to your source code
  3. Launch the debugger from VSCode
  4. Chrome will open with debugging capabilities ready

With these configurations in place, backend developers transitioning to Vue.js can effectively debug their applications using familiar tools and workflows.

Tags: VSCode Vue.js debugging Chrome DevTools Source Maps

Posted on Tue, 26 May 2026 20:23:35 +0000 by S_henry