Provide Angular build context to external tool configuration files
まだ誰も着手していません。
評価
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 初心者へのやさしさ
- 25/100
- issue の種類
- 機能追加
- 明瞭さ
- 説明が足りない
- 活発さ
- 停滞
- 技術スタック
- angular, tailwindcss, typescript
- 領域
- build-system, cli, tooling
調査の方向性
まず、ng build が angular.json のビルドオプションと設定をどのように読み取るかを確認し、次に #20015 の関連する PurgeCSS の議論を読んでください。実装を開始する前に、提案されている環境変数アプローチの中から決定する必要があります。完了の条件は、合意された設計、文書化された設定セマンティクス、設定のマージとプラットフォーム動作に対するカバレッジです。
索引モデルが issue の本文から書いたものです。
説明
🚀 Feature request
Command (mark with an x)
- build
Description
Spin off from PurgeCSS discussion in #20015.
It would be nice for external tool configuration files (like Tailwind) to have some knowledge about the Angular build context in order to conditionalize their configurations. This could allow ng build --configuration production to change the config used by other tools and affect their builds as well. This allows other tools in a project to be more intelligent about the intent of a build and do what the user expects.
Describe the solution you'd like
There are a couple possible implementations of this.
- Set an environment variable like
NG_BUILD_CONFIGS="foo,bar,baz". Then config files could do something like:
const enableOptimizations = process.env['NG_BUILD_CONFIGS'].split(',').includes('production');
This would decouple the Angular CLI from any specific tools and allow the individual tool configs to define the semantics for each configuration. Similarly, the semantics for each configuration are also defined directly in the tool's config file rather than angular.json. That seems weird to me, but arguably it's a benefit so 🤷♂️. It also means that the config needs some knowledge of Angular, which isn't too bad considering its in the config, not the tool library, but this can still be undesirable.
- Add an
envoption inangular.json. Each configuration in theangular.jsonfile could include anenvmap that looks like:
{
"projects": {
"my-project": {
"architect": {
"build": {
"options": {
"env": {
"MY_BUILD_ENV": "development",
},
},
},
"configurations": {
"production": {
"env": {
"MY_BUILD_ENV": "production",
},
},
},
},
},
},
}
The Angular CLI would parse and set the relevant environment variables during a build. Then tool configs could look for the project-specific environment variables like so:
const enableOptimizations = process.env['MY_BUILD_ENV'] === 'production';
This would still give users full control over the semantics of any given environment variable and they can choose its value on a per-configuration basis. The challenges here include merging multiple configuration environment variables which might conflict and that this environment would apply to all tools used by the Angular CLI. Users might also break something by setting a variable they probably shouldn't (such as PATH or other system variables) and breaking the CLI.
- Just have users set the environment variable on the command line:
MY_BUILD_ENV="production" ng build --configuration production
Then use that variable in the tool config just like previously:
const enableOptimizations = process.env['MY_BUILD_ENV'] === 'production';
This requires no effort on the Angular CLI side and users can do this today. The downside here is that it requires special knowledge of how to build a particular app. A new developer would reasonably expect ng build --configuration production to do everything it needs to, and then be surprised something didn't optimize because they didn't set MY_BUILD_ENV="production". Projects could wrap such a command into an npm run build:prod which sets the variable, but not everyone will use it. This is also a cross platform issue, as I don't think there is a Unix and Windows compatible way of doing this (see this question), so supporting both environment for build is more hassle for the user.
There are likely other possible implementations that have their own trade offs. We'll need to discuss this more and come to a decision on how to move forward here.
- 主要言語
- TypeScript
- スター
- 27k
- フォーク
- 11.8k
- 平均マージ
- 17時間 25分
- マージ済み PR(30日)
- 183
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
angular/angular-cli のほかの issue
-
area: @angular/build gemini-triaged
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
angular/angular-cli#33955 ·
-
area: @angular/cli gemini-triaged
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
angular/angular-cli#33055 · コメント 1 件 · リアクション 3 件 ·
-
angular/build:library area: @angular/build gemini-triaged
angular/angular-cli#34131 · 担当者 1 名 ·
-
angular/build:library area: @angular/build gemini-triaged
angular/angular-cli#34130 · 担当者 1 名 ·
-
angular/build:library area: @angular/build gemini-triaged
angular/angular-cli#34128 · 担当者 1 名 ·
angular/angular-cli の issue をすべて見る
似ている issue
-
clawsweeper:linked-pr-open clawsweeper:no-new-fix-pr clawsweeper:source-repro impact:message-loss issue-rating: 🦞 diamond lobster maturity:stable P2
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
Eynzof/Hermes-CN-Desktop#616 ·
-
ZCode 3.14.3 に対応する オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
supermomonga/zcode-acp#24 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
growthbook/growthbook#7100 ·
-
triage
難易度 1/5 1〜3時間 初心者へのやさしさ 88/100