4

I'm using my Angular App inside an Iframe, and I want to be able to change the path for the javascript files inside index.html after doing a build (ng build).

This is the command I use in order to build my Angular App:

npm run env && ng build --aot --prod --environment=prod

After doing it, in my dist folder I have this tree:

index.html
inline.318b50c57b4eba3d437b.bundle.js
main.d83bd9b8af8c676f706b.bundle.js
and etc

Looking inside index.html we can see the following:

<body>
...
<script type="text/javascript" src="inline.318b50c57b4eba3d437b.bundle.js"></script>
<script type="text/javascript" src="polyfills.5a5809ec73e38d8a32d3.bundle.js"></script>
<script type="text/javascript" src="scripts.7b67fa96a25429619fd6.bundle.js"></script>
<script type="text/javascript" src="main.d83bd9b8af8c676f706b.bundle.js"></script>
</body>

I want to change the build command somehow, maybe there is a flag I didn't saw or any other method to generate index.html with a different path for the javascript files as the following:

<body>
...
<script type="text/javascript" src="PathBefore/inline.318b50c57b4eba3d437b.bundle.js"></script>
<script type="text/javascript" src="PathBefore/polyfills.5a5809ec73e38d8a32d3.bundle.js"></script>
<script type="text/javascript" src="PathBefore/scripts.7b67fa96a25429619fd6.bundle.js"></script>
<script type="text/javascript" src="PathBefore/main.d83bd9b8af8c676f706b.bundle.js"></script>
</body>
Ron Yaari
  • 231
  • 3
  • 10

1 Answers1

3

set href base in build command

ng build --base-href /PathBefore/ 
Max CodeSmith
  • 467
  • 3
  • 13