Angular -CLI - how to add a prefix to a script tag in index.html

Angular-cli generates an index.html file during ng-build.

The application runs on a hardware proxy, which means that for all of its script tags, you must use the prefix "/ some / prefix /". Cli generates the following script tags.

<script type="text/javascript" src="inline.js"></script>
<script type="text/javascript" src="styles.b1a79a362dfcae386d67.bundle.js"></script>
<script type="text/javascript" src="main.2b9bcc2dcbe5c9cb526b.bundle.js"></script>

Is there a way to prefix the src of each tag with something?

+4
source share
1 answer

You need to install --base-hrefduring maintenance or creation, for example. ng serve --base-href '/some/prefix/' --aot.

--base-hrefinstalls a tag <base href='/some/prefix'>in your HTML file and adds such a prefix to all scripts and style sheets that are automatically detected.

, , base .

0

Source: https://habr.com/ru/post/1659367/


All Articles