angular / angular/angular-cli

Flatten glob "assets" to one output folder

Aperta
#14,158 11 commenti 9 reazioni 0 assegnatari Vedi su GitHub
area: @angular-devkit/build-angular feature feature: insufficient votes
Lingua principale
TypeScript
Stelle
27k
Fork
11.8k
Merge medio
14h 23m
PR unite (30g)
162

Descrizione

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

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Inizia dalla configurazione dell’esportazione degli asset e confronta il modo in cui ng serve, ng build --watch e una build normale elaborano il glob mostrato. La modifica è completata quando gli asset annidati possono essere emessi direttamente sotto dist/assets senza le cartelle intermedie module e assets, rimanendo disponibili anche per il workflow di serve in memoria.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
angular, typescript
Ambito
build-system, cli
Tipo di issue
Funzionalità
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
38/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.