ng serve
建構應用,並啟動開發伺服器,當檔案變化時重新建構。
Builds and serves your app, rebuilding on file changes.
ng serve <project> [options]
ng s <project> [options]
引數
引數 | 說明 |
---|---|
<project> | 要建構的專案名。可以是應用或函式庫。 The name of the project to build. Can be an application or a library. |
選項
選項 | 說明 |
---|---|
--allowed-hosts | 允許訪問開發伺服器的主機列表。 List of hosts that are allowed to access the dev server. |
--aot=true|false | 已棄用: 使用 browser 建構器中的 "aot" 選項代替。 Use the "aot" option in the browser builder instead. 使用預先(AOT)編譯進行建構。 Build using Ahead of Time compilation. |
--base-href=base-href | 已棄用: 使用 browser 建構器中的 "baseHref" 代替。 Use the "baseHref" option in the browser builder instead. 所建構的應用程式的 base URL。 Base url for the application being built. |
--browser-target=browser-target | 一個瀏覽器建構器目標,用來以 A browser builder target to serve in the format of |
--common-chunk=true|false | 已棄用: 使用 browser 建構器中的 "commonChunk" 代替。 Use the "commonChunk" option in the browser builder instead. 產生一個單獨的捆綁套件,其中包含跨多個捆綁套件使用的程式碼。 Generate a seperate bundle containing code used across multiple bundles. |
--configuration=configuration | 建構器的一個或多個命名配置,是一個逗號分隔的列表,就像在 angular.json 的 "configurations" 部分指定的一樣。 建構器使用這些命名配置執行給定的目標。 欲知詳情,參見 https://angular.cn/guide/workspace-config#alternate-build-configurations。 可以透過顯式指定 "--prod" 標誌來覆蓋它。 One or more named builder configurations as a comma-separated list as specified in the "configurations" section of angular.json. The builder uses the named configurations to run the given target. For more information, see https://angular.io/guide/workspace-config#alternate-build-configurations. Setting this explicitly overrides the "--prod" flag. 別名: -c |
--deploy-url=deploy-url | 已棄用: 使用 browser 建構器中的 "deployUrl" 代替。 Use the "deployUrl" option in the browser builder instead. 這些檔案將部署到的 URL。 URL where files will be deployed. |
--disable-host-check=true|false | 不要驗證連線的客戶端是否屬於允許的主機。 Don't verify connected clients are part of allowed hosts. 預設值: |
--help= | 在控制檯顯示關於本命令的幫助資訊。 Shows a help message for this command in the console. 預設值: |
--hmr=true|false | 啟用模組熱替換。 Enable hot module replacement. 預設值: |
--hmr-warning=true|false | 已棄用: 已經不起作用了。 No longer has an effect. 啟用 --hmr 選項時顯示警告。 Show a warning when the --hmr option is enabled. 預設值: |
--host=host | 要監聽的主機。 Host to listen on. 預設值: |
--live-reload=true|false | 是否要利用即時過載在更改時重新整理頁面。 Whether to reload the page on change, using live-reload. 預設值: |
--open=true|false | 在預設瀏覽器中開啟此 URL。 Opens the url in default browser. 預設值: 別名: -o |
--optimization=true|false | 已棄用: 使用 browser 建構器中的 "optimization" 選項代替。 Use the "optimization" option in the browser builder instead. 啟用建構輸出的優化。包括指令碼和樣式的最小化、搖樹優化、消除死程式碼和內聯字型等。欲知詳情,請參閱https://angular.cn/guide/workspace-config#optimization-configuration。 Enables optimization of the build output. Including minification of scripts and styles, tree-shaking, dead-code elimination, tree-shaking and fonts inlining. For more information, see https://angular.io/guide/workspace-config#optimization-configuration. |
--poll | 啟用輪詢並定義毫秒為單位的輪詢間隔。 Enable and define the file watching poll time period in milliseconds. |
--port | 要監聽的埠。 Port to listen on. 預設值: |
--prod=true|false | "--configuration=production" 的簡寫形式。 把建構配置的目標設定為產品環境。 預設情況下,產品環境目標是在工作空間配置中設定的,可以設定打包方式、搖樹優化限制、死程式碼移除限制等方面。 Shorthand for "--configuration=production". Set the build configuration to the production target. By default, the production target is set up in the workspace configuration such that all builds make use of bundling, limited tree-shaking, and also limited dead code elimination. |
--progress=true|false | 已棄用: 使用 browser 建構器中的 "progress" 代替。 Use the "progress" option in the browser builder instead. 在建構時將進度記錄到控制檯。 Log progress to the console while building. |
--proxy-config=proxy-config | 代理配置檔案。 Proxy configuration file. |
--public-host=public-host | 瀏覽器客戶端(或即時過載客戶端,如果啟用)用於連線開發伺服器的 URL。用於複雜的開發伺服器設定,例如帶有反向代理的伺服器。 The URL that the browser client (or live-reload client, if enabled) should use to connect to the development server. Use for a complex dev server setup, such as one with reverse proxies. |
--serve-path=serve-path | 要在其中啟動應用伺服器的路徑名。 The pathname where the app will be served. |
--serve-path-default-warning=true|false | 已棄用: 已經不起作用了。 No longer has an effect. 當 deploy-url/base-href 使用了不受支援的服務路徑時,顯示警告。 Show a warning when deploy-url/base-href use unsupported serve path values. 預設值: |
--source-map=true|false | 已棄用: 使用 browser 建構器中的 "sourceMap" 代替。 Use the "sourceMap" option in the browser builder instead. 輸出指令碼和樣式的原始碼對映資訊。欲知詳情,請參閱https://angular.cn/guide/workspace-config#source-map-configuration。 Output source maps for scripts and styles. For more information, see https://angular.io/guide/workspace-config#source-map-configuration. |
--ssl=true|false | 用 HTTPS 方式提供服務。 Serve using HTTPS. 預設值: |
--ssl-cert=ssl-cert | 用於提供 HTTPS 服務的 SSL 證書。 SSL certificate to use for serving HTTPS. |
--ssl-key=ssl-key | 用於提供 HTTPS 服務的 SSL 金鑰。 SSL key to use for serving HTTPS. |
--vendor-chunk=true|false | 已棄用: 使用 browser 建構器中的 "vendorChunk" 代替。 Use the "vendorChunk" option in the browser builder instead. 產生僅包含供應商函式庫的單獨捆綁套件。此選項只能用於開發階段。 Generate a seperate bundle containing only vendor libraries. This option should only used for development. |
--verbose=true|false | 將更多詳細資訊新增到輸出日誌記錄。 Adds more details to output logging. |
--watch=true|false | 在更改時重建。 Rebuild on change. 預設值: |