Angular-cli: ng build & hosted on Apache(httpd)

Created on 18 May 2016  路  3Comments  路  Source: angular/angular-cli

Hi I'm new to angular2 and angular-cli, great work for this command line tool.

  1. Windows 7
  2. ng --version
    angular-cli: 1.0.0-beta.1
    node: 5.9.1
    os: win32 x64
  3. I create app, generate component add route and ng serve works fine and application is served at http://localhost:4200/.
    With ng build(production: true) I create dist and content copy to application hosted on Apache server(http://localhost/myAngular2), but application is not working, because of broken links for js.
  4. LOG:
    http://localhost/vendor/reflect-metadata/Reflect.js Failed to load resource: the server responded with a status of 404 (Not Found)
    http://localhost/vendor/zone.js/dist/zone.js Failed to load resource: the server responded with a status of 404 (Not Found)
    http://localhost/vendor/systemjs/dist/system.src.js Failed to load resource: the server responded with a status of 404 (Not Found)
    http://localhost/vendor/es6-shim/es6-shim.js Failed to load resource: the server responded with a status of 404 (Not Found)
    localhost/:32 Uncaught ReferenceError: System is not defined
  5. Is any way to build generated apllication with some host or application prefix?

Regards, Tomaz

RFC / discussion / question

Most helpful comment

If you're serving it under http://localhost/myAngular2, you need to change the <base href="/"> tag in the generated dist/index.html.

Currently there is no way of doing it automatically, but there is an issue for it here https://github.com/angular/angular-cli/issues/646

All 3 comments

Yes you will got 404. In your index.html under dist. Try to change the path example below:
src="myAngular2/vendor/es6-shim/es6-shim.js

I think ng build -prod had some issues. But try to build just ng build

If you're serving it under http://localhost/myAngular2, you need to change the <base href="/"> tag in the generated dist/index.html.

Currently there is no way of doing it automatically, but there is an issue for it here https://github.com/angular/angular-cli/issues/646

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

_This action has been performed automatically by a bot._

Was this page helpful?
0 / 5 - 0 ratings