Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular cli copying files out of the assets folder

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

like image 611
David V Avatar asked Aug 10 '17 22:08

David V


1 Answers

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.

like image 170
DeborahK Avatar answered Nov 07 '22 19:11

DeborahK