angular / angular-cli

CLI tool for Angular
https://cli.angular.io
MIT License
26.73k stars 11.98k forks source link

Allow failing build if there are missing runtime assets #19952

Open dwilches opened 3 years ago

dwilches commented 3 years ago

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

petebacondarwin commented 3 years ago

Transferring to the CLI project.

angular-robot[bot] commented 2 years ago

Just a heads up that we kicked off a community voting process for your feature request. There are 20 days until the voting process ends.

Find more details about Angular's feature request process in our documentation.

angular-robot[bot] commented 2 years ago

Thank you for submitting your feature request! Looks like during the polling process it didn't collect a sufficient number of votes to move to the next stage.

We want to keep Angular rich and ergonomic and at the same time be mindful about its scope and learning journey. If you think your request could live outside Angular's scope, we'd encourage you to collaborate with the community on publishing it as an open source package.

You can find more details about the feature request process in our documentation.