angular / angular/angular-cli

Allow failing build if there are missing runtime assets

Open
#19,952 3 comments 0 reactions 0 assignees View on GitHub
area: @angular-devkit/build-angular feature feature: insufficient votes
Dominant language
TypeScript
Stars
27k
Forks
11.8k
Avg merge
14h 23m
Merged PRs (30d)
162

Description

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

Contributor guide

Open the contributing guide

Research direction

Start with the assets configuration in angular.json and trace how the @angular/cli build processes glob-based asset entries. Compare the requested files array behavior with the alternative failIfNoMatch option; done means missing required runtime assets cause the build to fail while existing glob usage remains supported.

Written by the indexing model from the issue text.

Assessment

Tech stack
angular, typescript
Domain
build-system
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.