Vscode Debug Vue Project

Source: Internet
Author: User

Prerequisite

You have to install Chrome and VS Code. Also make sure you have the latest version of the Debugger for Chrome extension installed in VS Code.

Before you can debug your Vue component from VS Code, you need to update the Webpack configuration to build the source map. Once this is done, our debugger has the opportunity to map the code in a compressed file back to its source file corresponding to its location. This ensures that you can debug in one application, even if your resources have been webpack optimized.

Open config/index.js and locate devtool the property. Update it to:

' Source-map ',

If you use vue-cli3 you need vue.config.js to set devtool the properties inside:

Module.exports = {  configurewebpack: {    'source-map'   }}

Go to the Debugger view, add a chrome configuration, and replace the content with the following

{  "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}/*"      }    }  ]}

Set breakpoints

Here response return data

Start Debugging

Use the following command on the terminal to open the application

NPM start

Go to Debug view, select ' vuejs:chrome ' configuration, then press F5 or click on the Green Play button

With a new Chrome instance open http://localhost:8080 , your breakpoint should now be hit.

For more information, please refer to the official documentation: Https://cn.vuejs.org/v2/cookbook/debugging-in-vscode.html

Vscode Debug Vue Project

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.