angular / angular/angular-cli

Allow failing build if there are missing runtime assets

Offen
#19,952 3 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
area: @angular-devkit/build-angular feature feature: insufficient votes
Vorherrschende Sprache
TypeScript
Sterne
27k
Forks
11.8k
Ø Merge
14 Std. 23 Min.
Gemergte PRs (30 T.)
162

Beschreibung

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

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Beginne mit der Assets-Konfiguration in angular.json und verfolge, wie der Build von @angular/cli Asset-Einträge auf Basis von Globs verarbeitet. Vergleiche das Verhalten des angeforderten files-Arrays mit der alternativen failIfNoMatch-Option; abgeschlossen ist die Aufgabe, wenn fehlende erforderliche Laufzeit-Assets dazu führen, dass der Build fehlschlägt, während die bestehende Verwendung von Globs weiterhin unterstützt wird.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
angular, typescript
Bereich
build-system
Issue-Typ
Feature
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.