kub*_*ube 2 debugging typescript webpack electron visual-studio-code
My Electron主进程使用TypeScript和捆绑的Webpack 2编写.
通过ts-loader和完成穿脱babel-loader.
发展模式,开始webpack --watch与主要工艺配置.
我无法使用VSCode调试器调试主进程.
在入口点添加断点src/main/index.ts没有任何影响.
.vscode/launch.js{
"configurations": [
{
"name": "Debug Main Process",
"type": "node",
"request": "launch",
"cwd": "${workspaceRoot}",
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron",
"runtimeArgs": [
"${workspaceRoot}",
"--remote-debugging-port=9222"
],
"sourceMaps": true
}
]
}
Run Code Online (Sandbox Code Playgroud)
webpack.development.js{
target: 'electron',
devtool: 'source-map',
entry: {
main: join(__dirname, 'src/main/index')
},
output: {
path: join(__dirname, 'app'),
filename: '[name].js'
}
}
Run Code Online (Sandbox Code Playgroud)
重要的是给VSCode提供源文件,该文件是程序的入口点,并在"program"密钥中指定它.
您还需要在"outFiles"Webpack生成的包中指定.
{
"configurations": [
{
"name": "Debug Main Process",
"type": "node",
"request": "launch",
"cwd": "${workspaceRoot}",
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron",
// This is the important stuff
"program": "${workspaceRoot}/src/main/index.ts"
"outFiles": [
"${workspaceRoot}/app/main.js"
],
"sourceMaps": true
}
]
}
Run Code Online (Sandbox Code Playgroud)
在Webpack配置中,您需要指定要在源映射中编写模块源文件的完整路径.
{
output: {
devtoolModuleFilenameTemplate: '[absolute-resource-path]'
}
}
Run Code Online (Sandbox Code Playgroud)
另外要注意选择未评估的源映射,以允许VSCode静态查找相应的入口点.
我用最小配置和更多解释创建了一个repo.
| 归档时间: |
|
| 查看次数: |
1654 次 |
| 最近记录: |