Reputation: 3216
I have an Angular 2 application in a subfolder of an ASP.NET project, and would like to bundle the Angular 2 application using the techniques from How to bundle an Angular app for production
The recommended approach there is to set up a project using Angular CLI. However I am having some trouble using that approach since it makes some assumptions about the project structure.
Assuming that the Angular 2 application is located in the subfolder /Angular2App/
it seems Angular CLI would like the index.html
to be located in /Angular2App/src/
, and when bundling the result is located in /Angular2App/dist/
and all references there from that folder's index.html
assume that bundles are located at /
.
However I would simply like the Angular 2 application to be available at /Angular2App/
.
Any ideas as to how I can configure Angular CLI in this way?
Upvotes: 1
Views: 868
Reputation: 2633
Use the base-href
flag to set a base url other than the root.
ng build --base-href=/Angular2App/
From the Angular docs:
If you copy the files into a server sub-folder, append the build flag, --base-href and set the appropriately.
For example, if the index.html is on the server at /my/app/index.html, set the base href to like this.
ng build --base-href=/my/app/
You'll see that the is set properly in the generated dist/index.html.
https://angular.io/guide/deployment
Upvotes: 1
Reputation: 3041
You should set deployUrl
when you build your angular application and then all path variables will have prefix /Angular2App/
. For example;
ng build --deployUrl "/Angular2App/"
Upvotes: 3