While working on my PWA app with Angular, I have implemented a watched build that automatically rebuilds my code whenever there are any changes:
ng build --output-path dist --watch
This process has been efficient so far.
In addition to this, I have set up a lite-server via the command line to host the build results from the dist folder:
lite-server
As a result, I can view the built app on localhost:3000. However, I am facing an issue with debugging in Visual Studio Code. I tried extending the launch.json file with a configuration to launch the server:
{
"name": "Launch via NPM",
"type": "node",
"request": "launch",
"cwd": "${workspaceRoot}",
"runtimeExecutable": "npm",
"runtimeArgs": [
"run-script", "runServer"
]
}
The script 'runServer' is defined in my package.json file as simply running 'lite-server'. Even after selecting and running this configuration, the server starts and the browser opens, but I am still unable to debug in Visual Studio Code by stopping at breakpoints.
I am unsure if it is possible to build the Angular code in a dist folder without just serving it using 'ng serve'. When using 'ng serve' along with the default Chrome launch configuration in VSC, debugging Angular works smoothly. However, I lose out on the PWA capabilities in that setup.
If anyone has a solution or idea that could work in this scenario, I would appreciate the help.