0

I started working on a company's project, and I've been told that to start the local development server I must first run the command: "package:serve": "ng build project-name --watch" and then: "start": "ng serve"

The problem in doing so, is that ng serve starts reloading as soon as ng build starts recompiling, so after each file change it refreshes the browser ~3 times and often doesn't show the new changes in the browser window until a 4th (manual) refresh.

Now as you can see, this is VERY uncomfortable to use. I wish that ng serve would refresh only 1 time, after the build is done.

Is there a better way, to run ng build and ng serve concurrently?

Bill P
  • 3,622
  • 10
  • 20
  • 32
Kyek
  • 137
  • 1
  • 2
  • 10
  • Check this package https://www.npmjs.com/package/concurrently – Pranoy Sarkar Sep 24 '19 at 09:17
  • @PranoySarkar This seemed promising, but it starts `ng serve` before `ng build` has compiled, so it crashes immedeately, and only `ng build --watch` is left running. The command I tried: `concurrently -n "package,serve" "npm run package:serve" "npm run start"` – Kyek Sep 24 '19 at 09:44

1 Answers1

1

I managed to solve it thanks to this other question: Angular serve library

I edited my tsconfig.json with the correct path to the library (not /dist/)

changed

    "paths": {
      "my-lib": [
        "dist/my-lib"
      ],
      ...

to

    "paths": {
      "my-lib": [
        "projects/my-lib/src/public-api"
      ],
      ...

Now I can use only ng serve and everything works correctly.

Kyek
  • 137
  • 1
  • 2
  • 10