Angular 7如何为dist中的图像指定文件夹 [英] Angular 7 how to specify folder for images in dist
问题描述
当我通过 dist
文件夹中的 ng build
命令构建项目时,我得到了带有所有其他资源的 js
文件,但是我想将所有图像和字体移动到单独的文件夹中,例如 assets
.有人可以帮我吗?
When I build project by ng build
command in dist
folder I got my js
files both with all other resources, but I want to move all images and fonts in separate folder like assets
. Can anybody help me?
更新:angular.json资产":["src/favicon.ico","src/资产"],
Update:
angular.json
"assets": [
"src/favicon.ico",
"src/assets"
],
在我拥有的组件的scss中:
in scss of component I have:
背景图片:url('assets/img/no-notifications.svg');
但是结果我进入了dist文件夹的下一个文件:
but in result I got in dist folder next file:
无通知.7e08682a570485d1c108.svg
目标保持图像路径与在scss文件中指定的图像路径相同: assets/img/no-notifications.svg
Goal is keep image path same as he has been specified in scss file:
assets/img/no-notifications.svg
推荐答案
如果您还不知道,则会在angular cli配置中添加一个新选项(因为
If you didn't already know, a new option was added into angular cli configuration (since v7.2.1) to copy css resources into another folder (relative to the output path).
"outputPath": "wwwroot",
"resourcesOutputPath": "images"
这篇关于Angular 7如何为dist中的图像指定文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!