將 nx 與 angular.json 一起使用時使用哪個構建器 (Which builder to use when using nx with angular.json)


問題描述

將 nx 與 angular.json 一起使用時使用哪個構建器 (Which builder to use when using nx with angular.json)

我遷移了一個現有的 Angular 項目以使用 nx。但我不太確定我是否以正確的方式做到了,因為性能很差。

我現在從

"builder": "@angular‑devkit/build‑angular:browser",

切換到

"builder": "@nrwl/web:build",

和似乎性能變得更好了。但是還有更多,例如:

"builder": "@nrwl/angular:webpack‑browser",
"builder": "@nrwl/angular:ng‑packagr‑lite",

使用web:build是否正確?有什麼區別?不幸的是,我在他們的網站上找不到很好的解釋。任何人都可以指出我正確的方向嗎?什麼時候使用哪個構建器?有什麼區別?


參考解法

方法 1:

I had the same problem after an Nx update, so did a little search on their official website. It's sad that they don't provide sufficient documentation for migrations. However, as they have documented clearly in their @nrwl/angular:webpack‑browser page,

The webpack‑browser executor is very similar to the standard browser builder provided by the Angular Devkit. It allows you to build your Angular application to a build artifact that can be hosted online. There are some key differences:

  • Supports Custom Webpack Configurations
  • Supports Incremental Building

A customWebpackConfig can be provided but is optional and still the Angular Devkit Configuration takes priority.

Nx configuration has now been updated to version: 2 and "builder": "@angular‑devkit/build‑angular:browser", was the standard way of specifying the executor in version: 1. Check your Nx configuration version and if you want to update it to 2, follow the instructions here.

方法 2:

I know it's been a couple of months, but for the sake of completeness: the ngPackagr one should be used for libraries only, as specified in their repo. Is that what you were trying to do? Also, what did you mean by poor performance?

If it's any reference (or for future visitors) I just created an NX app and it came with @angular‑devkit/build‑angular:browser by default.

(by timtosChamath KirindeAlejandro L.)

參考文件

  1. Which builder to use when using nx with angular.json (CC BY‑SA 2.5/3.0/4.0)

#nrwl #Angular #nrwl-nx #angular-cli






相關問題

Ng add @nrwl/workspace throws Cannot read property 'paths' of undefined (Ng add @nrwl/workspace throws Cannot read property 'paths' of undefined)

如何為非js框架創建原理圖? (How to create a schematic for non js framework?)

禁止在 Nrwl Nx 的同一庫中導入桶文件 (Disallow barrel file imports within the same library in Nrwl Nx)

如何強制 nrwl nx 尊重標籤更新? (How can I force nrwl nx to respect tag updates?)

將 Nx 工作區部署到 Google App Engine (Deploying Nx workspace to Google App Engine)

如何讓 Jest 正確轉換 node_modules/@nativescript/core?Jest + NativeScript + Angular + Nx (How can I get Jest to transpile node_modules/@nativescript/core properly? Jest + NativeScript + Angular + Nx)

使用 Nx 在 Jenkins 中進行 CI/CD 的最佳方式 (Best way for CI/CD in Jenkins with Nx)

如何使用短路徑在 Nx Workspace 中導入? (How to use short paths for importing in Nx Workspace?)

將 nx 與 angular.json 一起使用時使用哪個構建器 (Which builder to use when using nx with angular.json)







留言討論