7

can some one tell my why angular cli project is copying graphic files from the assets folder into the root of the output folder?

For example I have a graphic at src/assets/background.jpg, and I reference that graphic from my src/styles.css file:

body { background-image: url(./assets/background.jpg); } 

Now when I build my project using:

ng build --prod --output-hashing=none --output-path=target/output 

I now have the following generated output structure:

target/ouput ... background.jpg assets background.jpg 

The css is refernecing the copied version of the background file and everything works, but now I have two copies of the file. How can I reference this file from assets/background.jpg so I don't get two copies?

Thanks; David

5
  • can you show files in your dev root folder, .angular-cli.json "assets" section and what is your @angular/cli version ? Commented Aug 10, 2017 at 22:47
  • Have you searched your whole project for (string) background.jpg? You may be using it somewhere else. Commented Aug 10, 2017 at 22:54
  • The files in my dev root folder are: e2e src target node_modules .angular-cli.json .editorconfig karma.conf.js package-lock.json package.json pom.xml protractor.conf.js README.md tsconfig.json tslint.json Also, I just recently updated to angular-cli v1.2.6. I don't think I have modified the Assets sections of the .angular-cli.json file, that sections is set to: "assets": [ "assets", "favicon.ico" ], Commented Aug 11, 2017 at 14:28
  • i have the same problem any ideas? Commented Apr 13, 2018 at 13:35
  • Any suggestion ? Commented Mar 9, 2021 at 11:22

1 Answer 1

2

Because the idea is that everything you need to deploy will be in the specified output folder. Then you can deploy by copying the output folder to your server.

If the --prod build didn't copy the file, it would not be in the set of output files and would not get deployed without extra steps on your part.

Sign up to request clarification or add additional context in comments.

3 Comments

It is getting deployed, "ng build" is copying my entire assets folder to the output which already includes the background.jpg file, so after it also copies that file to the output root folder is it there twice.
You answer doesnt answer the question. His problem is why Angular duplicated the assets and uploads them twice
I read the question to be "can some one tell my why angular cli project is copying graphic files from the assets folder into the root of the output folder?"

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.