angular / angular/angular-cli

Allow failing build if there are missing runtime assets

未關閉
#19,952 3 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
area: @angular-devkit/build-angular feature feature: insufficient votes
主要語言
TypeScript
星號
27k
分支
11.8k
平均合併
14 小時 23 分鐘
30 天內合併 PR
162

描述

# 🚀 feature request

### Relevant Package
This feature request is for @angular/cli

### Description
If you have in the assets configuration in `angular.json`:
```
"assets": [
...
{
"glob": "jquery.min.js",
"input": "./node_modules/jquery/dist",
"output": "/assets/jquery"
},
...
]
```

And the glob doesn't match anything, no error is generated. This means the build can be broken because the `assets` folder doesn't contain all required runtime assets, but we won't realize until runtime.

### Describe the solution you'd like
The feature request is to add an array field `files` that can be used instead of `glob` to tell exactly which files to copy: `"files":
```
"assets": [
...
{
"files": ["jquery.min.js", "jquery.min.map"],
"input": "./node_modules/jquery/dist",
"output": "/assets/jquery"
},
...
]
```

### Describe alternatives you've considered

I considered listing the `jquery.min.js` file in the `scripts` section of `angular.json`, but this solution doesn't work perfectly for cases when it's not a "js" file I want in the assets folder. For example, mapbox comes with a folder with images, that I need copied to the assets folder.

An alternatively feature implementation I considered recommending was you could add an option `failIfNoMatch` to make the build fail if the glob doesn't match anything: `"failIfNoMatch": true`. But this solution is not as useful as the `files` one though, as the glob `jquery.min.{js,map}` would succeed even if it finds only one of the required files.

貢獻指南

開啟貢獻指南

研究方向

從 angular.json 中的 assets 設定開始,追蹤 @angular/cli 的 build 如何處理以 glob 為基礎的 assets 項目。比較要求的 files 陣列行為與替代的 failIfNoMatch 選項;完成條件是缺少必要的 runtime assets 時會導致 build 失敗,同時仍支援現有的 glob 用法。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
angular, typescript
領域
build-system
Issue 類型
功能
難度
4/5
預估耗時
3-5 天
活躍度
停滯
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。