I want to serve my Angular 2 application from a relative path, however I'm running into issues with how the angular-cli generates the index.html page.
The CLI inserts script references but because a leading slash isn't included, the html base
tag doesn't prefix the requests. EX of current cli output:
<script type="text/javascript" src="inline.bundle.js"></script>
<script type="text/javascript" src="vendor.bundle.js"></script>
<script type="text/javascript" src="main.bundle.js"></script>
What I want is for the CLI to allow me to customize this path. EX:
<script type="text/javascript" src="/myapp/inline.bundle.js"></script>
<script type="text/javascript" src="/myapp/vendor.bundle.js"></script>
<script type="text/javascript" src="/myapp/main.bundle.js"></script>
Is this possible with the CLI? The server that is hosting these files cannot use these default paths the way they're specified in the index.html page.
To understand how bundling works in an Angular app, you don't need to look further than the angular. json file. The angular. json file that is generated for your Angular app is the configuration file that is used by the underlying build system contained within the Angular CLI.
To Fix Error “This command is not available when running the Angular CLI outside a workspace Error”, Do Right-Click on yours project name in VS Code and Click “Open in Integrated Terminal” Option. It would open the project to your terminal and error would be fixed.
ng buildlink. Compiles an Angular application or library into an output directory named dist/ at the given output path.
You can use the parameter deploy-url param in angular-cli.json. If you put text 'app' to this param, you get paths like 'app/inline.bundle.js' in your index.html file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With