ng serve

Builds and serves your app, rebuilding on file changes.

ng serve <project> [options]
      
      ng serve <project> [options]
    
ng s <project> [options]
      
      ng s <project> [options]
    

参数

参数说明
<project>

The name of the project to build. Can be an app or a library.

选项

选项说明
--aot=true|false

Build using Ahead of Time compilation.

默认值: false

--baseHref=baseHref

Base url for the application being built.

--browserTarget=browserTarget

Target to serve.

--buildEventLog=buildEventLog

(experimental) Output file path for Build Event Protocol events

--commonChunk=true|false

Use a separate bundle containing code used across multiple bundles.

默认值: false

--configuration=configuration

A named build target, as specified in the "configurations" section of angular.json. Each named target is accompanied by a configuration of option defaults for that target.

别名: -c

--deployUrl=deployUrl

URL where files will be deployed.

--disableHostCheck=true|false

Don't verify connected clients are part of allowed hosts.

默认值: false

--evalSourceMap=true|false

Output in-file eval sourcemaps.

默认值: false

--help=
true|false|json|JSON

Shows a help message for this command in the console.

默认值: false

--hmr=true|false

Enable hot module replacement.

默认值: false

--hmrWarning=true|false

Show a warning when the --hmr option is enabled.

默认值: true

--host=host

Host to listen on.

默认值: localhost

--liveReload=true|false

Whether to reload the page on change, using live-reload.

默认值: true

--open=true|false

Opens the url in default browser.

默认值: false

别名: -o

--optimization=true|false

Enables optimization of the build output.

默认值: false

--poll

Enable and define the file watching poll time period in milliseconds.

--port

Port to listen on.

默认值: 4200

--prod=true|false

When true, sets the build configuration to the production target. All builds make use of bundling and limited tree-shaking. A production build also runs limited dead code elimination.

默认值: false

--progress=true|false

Log progress to the console while building.

默认值: false

--proxyConfig=proxyConfig

Proxy configuration file.

--publicHost=publicHost

Specify the URL that the browser client will use.

--servePath=servePath

The pathname where the app will be served.

--servePathDefaultWarning=true|false

Show a warning when deploy-url/base-href use unsupported serve path values.

默认值: true

--sourceMap=true|false

Output sourcemaps.

默认值: true

--ssl=true|false

Serve using HTTPS.

默认值: false

--sslCert=sslCert

SSL certificate to use for serving HTTPS.

--sslKey=sslKey

SSL key to use for serving HTTPS.

--vendorChunk=true|false

Use a separate bundle containing only vendor libraries.

默认值: false

--vendorSourceMap=true|false

Resolve vendor packages sourcemaps.

默认值: false

--verbose=true|false

Adds more details to output logging.

默认值: false

--watch=true|false

Rebuild on change.

默认值: true