安裝@babel/node
npm i @babel/node
目錄結(jié)構(gòu)
.
├── .babelrc
├── .vscode
│ └── launch.json
├── package.json
配置launch.json
關(guān)鍵點:
- 配置
runtimeExecutable
, 用babel-node來debug - 開啟sourcemap
"sourceMaps": true,
- 配置env, 不影響babel其他功能
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "current file",
"program": "${file}",
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/babel-node",
"sourceMaps": true,
"env": {
"BABEL_ENV": "debug"
}
}
]
}
配置.babelrc
說明:
debug
對應(yīng)launch.json中的 "BABEL_ENV": "debug"
{
"presets": ["@babel/preset-env"],
"env": {
"debug": {
"sourceMaps": "inline",
"retainLines": true
}
}
}
givencui博客首發(fā), 轉(zhuǎn)載請注明來自GivenCui