this is probably a newbie question, but I couldn't find any answers to it here or on angular documentation. Let's say I have a simple Angular application (the hero editor from the angular.io tutorial for instance) that I want to distribute without yet knowing under which path it will run on my webserver. It could be under:
Put differently, I'd need the generated sources (the index.html and its angular associated js files) to be fully working under any path (I guess that's why relative path are for...) currently my generated sources only work if I put them at the root dir my server, because of the
<base href="/">
npm deploy has generated in the index.html probably...I tried naively to change it to
<base href="./">
in order that my browser interpret the path of the included JS files as relative to the index.html. With this, my browser correcly finds the JS files, however the angular app is no longer working (blank page...).
Any idea of what should be the proper "angular-way" of doing that?
Thanks for your help in advance!
Basic deployment to a remote serverlink For the simplest deployment, create a production build and copy the output directory to a web server. Copy everything within the output folder ( dist/project-name/ by default) to a folder on the server. Configure the server to redirect requests for missing files to index.html .
Because these files are static, you can host them on any web server capable of serving files; such as Node. js , Java, . NET, or any backend such as Firebase, Google Cloud, or App Engine.
Found a solution that's working for me and doesn't look too ugly:
ng build --base-href "./"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With