Allow failing build if there are missing runtime assets

Open
#19,952 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

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

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.

Description

area: @angular-devkit/build-angular feature feature: insufficient votes

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

Dominant language
TypeScript
Stars
27k
Forks
11.8k
Avg merge
16h 35m
Merged PRs (30d)
176

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from angular/angular-cli

All issues in angular/angular-cli

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.