adamsfamily
adamsfamily

Reputation: 1974

How can define default 'ng serve' parameters using angular.json?

I have a monorepo setup with multiple Angular 9 applications (build by nrwl nx):

fontend-client
fronted-admin

I can easily start either of the applications with:

npm start frontend-client
npm start frontend-admin

However, in order to remotely debug the applications I need to pass additional parameters to ng serve and therefore these are the full commands:

npm start frontend-client -- --host 0.0.0.0 --disable-host-check
npm start frontend-admin -- --host 0.0.0.0 --disable-host-check

How can I save —host and —disable-host-check as default parameters in angular.json?

Upvotes: 1

Views: 1434

Answers (1)

Saghi Shiri
Saghi Shiri

Reputation: 617

You can do it by define a custom script in package.json file:

"scripts": {
  "start-client": "ng serve frontend-client -- --host 0.0.0.0 --disable-host-check",
  "start-admin": "ng serve frontend-admin-- --host 0.0.0.0 --disable-host-check",
}

and in your command you can use:

npm run start-client
npm run start-admin

Upvotes: 1

Related Questions