简体   繁体   English

将cli cli复制到资源文件夹之外

[英]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? 有人可以告诉我为什么angular cli项目将图形文件从资产文件夹复制到输出文件夹的根目录吗?

For example I have a graphic at src/assets/background.jpg, and I reference that graphic from my src/styles.css file: 例如,我在src / assets / background.jpg上有一个图形,并且从我的src / styles.css文件中引用了该图形:

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. CSS正在引用后台文件的复制版本,并且一切正常,但是现在我有该文件的两个副本。 How can I reference this file from assets/background.jpg so I don't get two copies? 如何从assets / background.jpg引用此文件,所以我得不到两个副本?

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. 如果--prod构建未复制文件,则它将不在输出文件集中,并且无需您执行额外的步骤就不会进行部署。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Angular-cli - 如何将assets文件夹中的字体图标链接到css - Angular-cli - How to link font icons inside the assets folder to css 使用 Angular 7 cli 解析 css 中的资产路径 - Resolving assets path in css with Angular 7 cli Angular 资产 static 文件未找到 - Angular assets static files not found Angular 2 从 assets 文件夹加载 CSS 背景图像 - Angular 2 Load CSS background-image from assets folder dist 文件夹子目录中的 Output fonts、css 文件和其他资产 - Output fonts, css files and other assets in a subdirectory of the dist folder 如何在index.html中的资产文件夹内设置文件 - How to set files inside the assets folder in index.html 从Android WebView中的Assets文件夹加载CSS和JS文件 - Load CSS and JS files from assets folder in android webview Python Plotly Dash 有没有办法在 assets 文件夹外使用 Css 文件? / 拥有多个资产文件夹 - Python Plotly Dash Is there a way to use Css files outside the assets folder? / Have multiple assets folders 在Angular 2 / Angular-CLI中保持CSS不受JS限制 - Keeping CSS out of JS in Angular 2/Angular-CLI 如何在视图加载之前加载/导入 css 和资产文件(角度) - How to load/import css and assets files before the view loads (Angular)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM