遍寻无果,网上的内容大多不靠谱,终于找到一篇帖子:https://juejin.cn/post/6977213558790553630,估计是vue3的vue.config.js有特殊要求:
新增configureWebpack配置:
# 传递config参数进去
configureWebpack: (config) => {
config.devtool = 'source-map'
},
css: {
sourceMap: true,
},
lanuch.json中如下,即可:
{
// 使用 IntelliSense 了解相关属性。
// 悬停以查看现有属性的描述。
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "chrome",
"request": "launch",
"name": "Launch Chrome against localhost",
"url": "http://127.0.0.1:8080",
"webRoot": "${workspaceFolder}/src",
"breakOnLoad": true,
"sourceMaps": true,
"sourceMapPathOverrides": {
"webpack:///./*": "${webRoot}/*",
"webpack:///src/*": "${webRoot}/*",
"webpack:///./src/*": "${webRoot}/*",
"webpack:///./src/*.js": "${webRoot}/*.js",
"webpack:///./*.vue": "${webRoot}/*.vue"
}
]
}