[Fixed]-Adding prefix path to static files in Angular using angular-cli


You can use –deploy-url to prefix path of your generated static files. ng build --deploy-url /static/. It will prefix path of js files with /static/ in generated index.html like this:

<script type="text/javascript" src="/static/inline.bundle.js"></script>

From help doc:

--deploy-url (String) URL where files will be deployed.


ng build --prod --deploy-url=example.com/scripts/

Updated answer based on comments.


Using angular CLI 6.1.1

This how I do it, you need to use the build flag --base-href


ng build --prod --base-href=/dist/my-app/

and I access the site like this

Official document reference here

Leave a comment