Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flatten glob "assets" to one output folder #14158

Open
Nkmol opened this Issue Apr 14, 2019 · 1 comment

Comments

Projects
None yet
2 participants
@Nkmol
Copy link

Nkmol commented Apr 14, 2019

馃殌 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:

              {
                "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.

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.

@alan-agius4

This comment has been minimized.

Copy link
Collaborator

alan-agius4 commented Apr 15, 2019

Hi, thanks for reporting this.

Thinking about this more flattening the assets output is dangerous as this might cause file collisions since non of the assets files gets fingerprinted and a file with the same name can exist in a different nested folder.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can鈥檛 perform that action at this time.