问题
I've setup the Debugging with Chrome and it works reasonably well. However, every time I make a change & save the .htm file, I have to click the Restart icon in the toolbar for the changes to propagate to the instance of Chrome.
Is there a way for VS Code to "restart" when I save the file?
P.S. I am editing a local file (no web servers involved).
回答1:
I wanted to do exactly the same thing and accomplished it by installing an extension that allows me to execute a VS Code extension command when a file is saved.
The extension is Save and Run Ext and is a fork off of another extension but allows you to execute VS Code extension commands.
I added the following configuration to my settings.json
file:
{
"saveAndRunExt": {
"commands": [
{
"match": "\\.(css$|js$|html$)",
"isShellCommand": false,
"cmd": "workbench.action.debug.restart"
}
]
}
}
What this does is whenever a .css, .js, or .html file is saved, it will restart the debugger. You could of course configure it to do whatever you want.
An alternative (one step) solution is instead of saving the file, just restart the debugger, and it automatically saves all files and changes are propagated to Chrome.
来源:https://stackoverflow.com/questions/47564351/how-to-restart-on-save-in-visual-studio-code