Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What server does ng serve use when using Angular CLI 1.6.0?

What server does this Angular CLI command use, when using Angular CLI 1.6.0?

ng serve

Since webpack is now being used by the Angular CLI for the website bundling, does that mean ng-serve is using the webpack-dev-server (which is a Node.js Express server)? There is some indication in the following Q/A that ng serve possibly used to piggyback off a server used by Ember:

What happens when you run ng serve?

like image 510
Chris Halcrow Avatar asked Dec 07 '17 01:12

Chris Halcrow


People also ask

What server does ng serve use?

By default for ng serve CLI uses builder dev-server .

What server does Angular CLI use?

And here is the first obstacle that appears before every Angular CLI newbie: the Angular project runs on its own server (which runs by default at http://localhost:4200).

How does Angular ng serve work?

ng serve is a great command to use when developing your application locally. It starts up a local development server, which will serve your application while you are developing it. It is not meant to be used for a production environment.

What is the difference between ng serve and Ng serve?

Difference between ng serve and ng buildThe ng serve command is intentionally for fast, local and iterative developments and also for builds, watches and serves the application from a local CLI development server. The ng build command is intentionally for building the apps and deploying the build artifacts.


2 Answers

Try ng eject This command will override your package.json and also generates a file called webpack.config.js in your root directory.

That will give you all the current webpack configuration that your project is using.

When you do that, in your package.json, this is what you'll find :

"scripts": {
    "eject": "ddc eject",
    "build": "webpack",
    "start": "webpack-dev-server",
    "test": "karma start ./karma.conf.js",
    "pree2e": "webdriver-manager update --standalone false --gecko false --quiet",
    "e2e": "protractor ./protractor.conf.js"
  },

As you can see, npm start is using webpack-dev-server.

NOTE: To undo your changes, use git, otherwise AngularCli doesn't provide a way of undoing

like image 172
Milad Avatar answered Oct 19 '22 03:10

Milad


Yup, its using webpack-dev-server. You can look at the source-code of the ng eject command:

https://github.com/angular/angular-cli/blob/6449a753641340d8fc19a752e1a1ced75f974efa/docs/documentation/1-x/eject.md

like image 25
Sonu Kapoor Avatar answered Oct 19 '22 02:10

Sonu Kapoor