angular / angular/angular-cli

Flatten glob "assets" to one output folder

Ouverte
#14,158 11 commentaires 9 réactions 0 personnes assignées Voir sur GitHub
area: @angular-devkit/build-angular feature feature: insufficient votes
Langage dominant
TypeScript
Étoiles
27k
Forks
11.8k
Merge moyen
14 h 23 min
PR mergées (30 j)
162

Description

# 🚀 Feature request

```
- [ ] new
- [x] build
- [x] serve
- [ ] test
- [ ] e2e
- [ ] generate
- [ ] add
- [ ] update
- [ ] lint
- [ ] xi18n
- [ ] run
- [ ] config
- [ ] help
- [ ] version
- [ ] doc
```

### Description
I am currently working with nested assets folder per entity map. Currently, I am using the following assets export settings:

```json
{
"glob": "**/assets/**/*",
"input": "src/app",
"output": "/assets",
"ignore": ["**/*.ts"]
}
```

Imagine having the following file structure:

```
src
├── app
| ├── module-folder
| | ├── assets
| | │ ├── images
| | │ │ └── image1.png
| ├──other-module-folder
| | ├── assets
| | │ ├── images
| | │ │ └── image2.png
```

### What I get

This would result in the following `dist/` file structure:

```
dir
├── assets
| ├── module-folder
| | ├── assets
| | │ ├── images
| | │ │ └── image1.png
| ├──other-module-folder
| | ├── assets
| | │ ├── images
| | │ │ └── image2.png
```

### What I want to have

```
dir
├── assets
| ├── image1.png
| └── image2.png
```

### What I have tried

I have tried to use a custom script to move the assets files manually in a flatten way to the dir folder.

```sh
for file in ./src/app/**/assets/**/*.*; do cp "$file" "./dist/assets/$(basename -- "$file")" ;done
```

This, however, does not work in combination with `ng serve` as the files are in-memory, and also does not work with the `ng build --watch` as I am unsure how to activate script after it has been built.

---

I would love to get some insight into the best approach. Maybe this is simply using an already existing flow. From my point of view, this should be included as functionality, as the nested folder structure strategy seems to be one of the more common approaches.

Guide de contribution

Ouvrir le guide de contribution

Piste de recherche

Commencez par la configuration d’exportation des assets et comparez la manière dont ng serve, ng build --watch et un build normal traitent le glob indiqué. La modification est terminée lorsque les assets imbriqués peuvent être émis directement sous dist/assets sans les dossiers intermédiaires module et assets, tout en restant disponibles pour le workflow de serve en mémoire.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
angular, typescript
Domaine
build-system, cli
Type d'issue
Fonctionnalité
Difficulté
4/5
Temps estimé
3-5 jours
Activité
À l'abandon
Clarté
Plutôt claire
Accessibilité débutants
38/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.