I am running Vue with Vite in VSCode on Windows 10. I have the NPM Scripts shortcuts that builds the project when clicked on. I added the following binding to keybindings.json below and works nicely to launch my site as expected:
{
"key": "alt+g",
"command": "workbench.action.terminal.sendSequence",
"args": {
"text": "npm run dev\r"
},
},
Afterwards, I have to press the "o" to invoke the Vite "open the browser" command to launch the browser. I would like to incorporate the open command into the keybinding and I have tried several things including changing that text line to:
"text": "npm run dev\r && echo 'o'\r"
// OR
"text": "npm run dev\r && start chrome"
Any ideas how to do that?
Another way to open your browser automatically when running npm run dev
is to add the following to your vite.config.js file:
server: {
open: true, // This will open the browser automatically
}