0

I already have a local dev server running. Because of some technical reasons it would be much more convenient not to have to run the proxy- proxy.conf.json (cookies from one app to the other, data getting passed).

I have looked around on the angular website, and the quick start guide promotes the CLI. Is there a way I can run the CLI without the need to run the server on localhost:4200(on dev mode)? I have also tried the biggest Angular seed project I could find.

https://github.com/angular/angular-seed

The seed project also depends on running it's own server. Basically, how do I just watch the files and be able to debug real time? I don't care about having to reload the page. I cannot even find a reference to setting up an Angular project from scratch. Any help would be appreciated.

5
  • 1
    what you mean by own dev server? Commented Nov 10, 2017 at 21:10
  • I have a local server running with services. It also serves up other webapps. Commented Nov 10, 2017 at 21:13
  • 1
    you want to deploy both the apps in a same dev server? Commented Nov 10, 2017 at 21:14
  • 1
    Sounds like you could just put a reverse-proxy in front of it, and send the requests to your web server on port 80, and have it forward the request to port 4200 (you can change this in angular-cli.json file) Commented Nov 10, 2017 at 21:16
  • I have multiple web apps running on the local server. They are going to be joined to each other. Having 2 run on 8080 and 1 on 4200 (even with proxy makes it hard to integrate). I already tried to proxy using Angular CLI, unfortunately it doesn't work with my use case even though I got it running. Commented Nov 10, 2017 at 21:21

1 Answer 1

1

I figured this out. Here is my cli version because watch was broken in older Angular CLI versions.

"@angular/cli": "1.5.2",
"@angular/compiler-cli": "^5.0.0",
"@angular/language-service": "^5.0.0"

https://github.com/angular/angular-cli/issues/2511

So if you want to run it in your own server. You will build the project, debug from the dist location, and as you make changes, the dist folder will keep getting rebuild.

ng build --watch --base-href /path/to/your/dist/

It does not auto reload, you do have to refresh the page.

What the base-href does is change the path the site runs on. So if you use localhost:8080/index.html you can skip the base-href. Otherwise in your dist folder index.html the following lines will be changed automatically.

  <title>SampleApp</title>
  <base href="/path/to/your/dist/">
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.