Angular 2 CLI - Deployment

I created an Angular 2 application using the Angular 2 CLI. My problem now is that I want to deploy the application on a local server as an intermediary for others to view.

Most manuals using the Angular 2 CLI display a folder distthat appears to have been generated when the project was first created using the CLI. I can only generate a folder distusing ng build. I assume that the Angular 2 CLI has changed, initially the folder distwas part of the original folder structure, but now it is only generated when used ng build?

As a test, I copied the generated folder distto wwwthe WAMP server folder [ http: // localhost: 8080 / Project / dist /] to try and run the application ... The browser console shows:

Failed to load resource: the server responded with a status of 404 (Not Found)      http://localhost:8080/inline.js
Failed to load resource: the server responded with a status of 404 (Not Found)      http://localhost:8080/bundle.js

It searches for all resources in the root directory of the local server, and does not set the root to the location of index.html in the folder dist. All images and icons have the same problem ... I believe that I was not able to configure something for relative paths ... What should I do?

+3
source share
1 answer

First of all, you can specify the output path of the command ng build, so manual copying is not required. For example: ng build --output-path /var/www/app_foo/root/.

-, , index.html - <base href="/path">. ng build --base-href /path/.

, : ng build --base-href /Project/dist/.

+5

Source: https://habr.com/ru/post/1659369/


All Articles