'How to build a peer project automatically, if changes exist, in Visual Studio Code?

In a VS Code workspace I have 2 projects, one is a React web app and the other is a vscode extension which uses this app in a webview. This requires to create a production build of the web app to have the files available in the webview.

When I start debugging the extension code, I would like the React app to update the production build automatically when something changed in the web app, before debugging actually starts.

I know a build task could be used to do the production build, however that takes quite a moment, so I want this only to happen if something changed, actually. How can this be implemented?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source