What server does ng serve use when using Angular C

2019-02-10 00:06发布

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:

https://stackoverflow.com/questions/37137521/what-happens-when-you-run-ng-serve

2条回答
不美不萌又怎样
2楼-- · 2019-02-10 00:06

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

查看更多
Viruses.
3楼-- · 2019-02-10 00:14

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/master/packages/%40angular/cli/tasks/eject.ts#L552

查看更多
登录 后发表回答