angular / angular/angular-cli

Allow failing build if there are missing runtime assets

Đang mở
#19,952 3 bình luận 0 reaction 0 người được giao Xem trên GitHub
area: @angular-devkit/build-angular feature feature: insufficient votes
Ngôn ngữ chính
TypeScript
Star
27k
Fork
11.8k
Merge trung bình
14 giờ 23 phút
Pull request đã merge (30 ngày)
162

Mô tả

# 🚀 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.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Hướng nghiên cứu

Bắt đầu với cấu hình assets trong angular.json và theo dõi cách build của @angular/cli xử lý các mục assets dựa trên glob. So sánh hành vi của mảng files được yêu cầu với tùy chọn failIfNoMatch thay thế; hoàn thành khi các assets runtime bắt buộc bị thiếu khiến build thất bại, đồng thời việc sử dụng glob hiện có vẫn được hỗ trợ.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
angular, typescript
Lĩnh vực
build-system
Loại issue
Tính năng
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
35/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.