in your package.json, you could set the base-href when you build the "dist":
{
"name": "projectname",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build --base-href /bar-chart-4/",
... snip...
}
This will prepend "/bar-chart-4/" in front of all your references:
<body>
<app-root></app-root>
<script src="/bar-chart-4/runtime-es2015.js" type="module"></script>
<script src="/bar-chart-4/runtime-es5.js" nomodule defer></script>
<script src="/bar-chart-4/polyfills-es5.js" nomodule defer></script>
<script src="/bar-chart-4/polyfills-es2015.js" type="module"></script>
<script src="/bar-chart-4/styles-es2015.js" type="module"></script>
<script src="/bar-chart-4/styles-es5.js" nomodule defer></script>
<script src="/bar-chart-4/vendor-es2015.js" type="module"></script>
<script src="/bar-chart-4/vendor-es5.js" nomodule defer></script>
<script src="/bar-chart-4/main-es2015.js" type="module"></script>
<script src="/bar-chart-4/main-es5.js" nomodule defer></script>
</body>
NOTE: I, too, had to do this because I'm deploying the client UI (angular) "dist" folder as part of a Spring application WAR file [deployed on tomcat] and we always define a context root (ex: https://myserver.ext/myApp). So I have a gradle bruild script in my application which calls NpmTask "run build" and my package.json defines the context root (ng build --base-href /myapp) as defined above. That way, I can code the UI using the rapid "ng serve" and I can also build the dist and define the context root in the "ng build" for when I deploy a new version to tomcat.