Search code examples
angularasp.net-coreangular-cliazure-service-fabric

angular CLI, add /wwwroot to Index js scripts urls on ng build


We have an application of angular 2 inside asp.net core, which runs in a cluster of Azure Service Fabric, the small problem we have is that when you run ng build, the index.html file is with the following references:

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

but we need them to be as follows:

<script type="text/javascript" src="/Meteoro/Meteoro.UI/inline.bundle.js">
</script>
<script type="text/javascript"src="/Meteoro/Meteoro.UI/polyfills.bundle.js"
</script>
<script type="text/javascript" src="/Meteoro/Meteoro.UI/styles.bundle.js">
</script>
<script type="text/javascript" src="/Meteoro/Meteoro.UI/vendor.bundle.js">
</script>
<script type="text/javascript" src="/Meteoro/Meteoro.UI/main.bundle.js">
</script>

That is, add "/Meteoro/Meteoro.UI/{file}.js" to the URL

Thank you


Solution

  • You can configure this in your angular-cli.json

    "apps": [
        {
            "deployUrl": "/Meteoro/Meteoro.UI/"
        }
    ]
    

    This will append that path to your index.html resources. Alternatively you can add it to your build command

    ng build --deploy-url=/Meteoro/Meteoro.UI/