Skip to content

dubug 的时候 onstart钩子没有触发 #277

@TheShining

Description

@TheShining

在vscode 中,第一次,debug的时候,onstart钩子没有触发,只有修改main.js 后 Hot Restart,然后才触发onstart钩子
{
entry: 'src/main/index.js',
onstart({ startup }) {
console.log('onstart')
// 修改 main 代码后自动重启
startup([
'.',
'--no-sandbox',
'--sourcemap',
// For Chrome devtools
'--remote-debugging-port=9222'
])
},
}

下面是我的 launch.json 配置

    {
        "name": "Debug Main Process",
        "type": "node",
        "request": "launch",
        "runtimeExecutable": "${workspaceRoot}/node_modules/.bin/vite",
        "windows": {
            "runtimeExecutable": "${workspaceRoot}/node_modules/.bin/vite.cmd"
        },
        "console": "integratedTerminal"
    },

直接通过 npx vite 第一次启动是可以触发 onstart钩子的

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions