angular / angular/angular-cli

Flatten glob "assets" to one output folder

Offen
#14,158 11 Kommentare 9 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
area: @angular-devkit/build-angular feature feature: insufficient votes
Vorherrschende Sprache
TypeScript
Sterne
27k
Forks
11.8k
Ø Merge
14 Std. 23 Min.
Gemergte PRs (30 T.)
162

Beschreibung

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

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Beginne mit der Konfiguration für den Asset-Export und vergleiche, wie ng serve, ng build --watch und ein regulärer Build den angegebenen Glob verarbeiten. Die Änderung ist abgeschlossen, wenn verschachtelte Assets direkt unter dist/assets ohne die zwischengeschalteten Ordner module und assets ausgegeben werden können und weiterhin für den In-Memory-Serve-Workflow verfügbar sind.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
angular, typescript
Bereich
build-system, cli
Issue-Typ
Feature
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
38/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.