I'm so embarrassed, I've been writing about the
vue2source code all this time.....
Approach
All you need to do is enable sourcemap generation in vue3. For the project template, you can use the official vue template or any raw index.html setup that references the relevant packages or libraries. In the former case, it is likely that the package is shared, with the vue3 source code being built and then linked globally. In your project, simply remove the official vue remote package link and use the local package instead.
Related Debugging Configuration and Adjustments
The current source code build uses rollup and requires sourcemap. This needs to be added to the output related configuration, located in vue/scripts/config.js.
output: {
file: opts.dest,
format: opts.format,
banner: opts.banner,
name: opts.moduleName || 'Vue',
exports: 'auto',
+ sourcemap: true
}
{
"version": "0.2.0",
"configurations": [
// 调试 npm run build 或者类似脚本
{
"name": "vue build",
"request": "launch",
"runtimeArgs": [
"run",
"build"
],
"runtimeExecutable": "npm",
"skipFiles": [
"<node_internals>/**"
],
"type": "node",
"cwd": "${workspaceFolder}/vue"
},
// 远程 url 调试, 这里面要注意 outFiles, 此处未加, 实际需要加
{
"type": "msedge",
"request": "launch",
"name": "vue-project",
"url": "http://localhost:5173/",
"webRoot": "${workspaceFolder}/vue-project"
},
// 原始 index.html 调试, 同上个原理一致
{
"type": "msedge",
"request": "launch",
"name": "raw-html",
"url": "file:///C:/Users/14094/code/vue-debug/raw/index.html",
"webRoot": "${workspaceFolder}/raw",
"outFiles": [
"${workspaceFolder}/vue/**/*.js",
]
}
]
}
TODO: Debug video
Comments (0)
No comments yet. Be the first to leave one!