angular-cliangular-cli-v7

Is this possible to change script path in index.html file after build completed?


I have one angular-cli application, when i give ng build command it creates build file which has index.html file.

In index.html file, scripts paths are referred like below:

<script type="text/javascript" **src="runtime.js"**></script>
<script type="text/javascript" **src="polyfills.js"**></script>
<script type="text/javascript" **src="styles.js"**></script>
<script type="text/javascript" **src="vendor.js"**></script>
<script type="text/javascript" **src="main.js"**></script>

But i want to change that script like below,

<script type="text/javascript" **src="~/runtime.js"**></script>
<script type="text/javascript" **src="~/polyfills.js"**></script>
<script type="text/javascript" **src="~/styles.js"**></script>
<script type="text/javascript" **src="~/vendor.js"**></script>
<script type="text/javascript" **src="~/main.js"**></script>

Is it possible to change the path without using find and replace method?


Solution

  • I have found answer for my question in here.

    Please check here

    "deployUrl": "/app/", this property helps me to achieve my requirement

    Update, 2023 / Angular 16: "deployUrl" has been replaced by "baseHref". This property is added angular.json inside of architect/build/options