简体   繁体   中英

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM