angular / angular/angular-cli

Flatten glob "assets" to one output folder

Aberta
#14,158 11 comentários 9 reações 0 responsáveis Ver no GitHub
area: @angular-devkit/build-angular feature feature: insufficient votes
Linguagem predominante
TypeScript
Estrelas
27k
Forks
11.8k
Merge médio
14h 23min
PRs com merge (30d)
162

Descrição

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

Guia de contribuição

Abrir o guia de contribuição

Direção de pesquisa

Comece pela configuração de exportação de assets e compare como ng serve, ng build --watch e um build normal processam o glob mostrado. A alteração estará concluída quando assets aninhados puderem ser emitidos diretamente em dist/assets sem as pastas intermediárias module e assets, permanecendo disponíveis para o fluxo de trabalho de serve em memória.

Escrita pelo modelo de indexação a partir do texto da issue.

Avaliação

Stack de tecnologia
angular, typescript
Domínio
build-system, cli
Tipo de issue
Funcionalidade
Dificuldade
4/5
Tempo estimado
3-5 dias
Status de atividade
Estagnada
Clareza
Razoavelmente clara
Facilidade para iniciantes
38/100

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.