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",源代码/资产"],
Update:
angular.json
"assets": [
"src/favicon.ico",
"src/assets"
],
在我有的组件的 scss 中:
in scss of component I have:
background-image: url('assets/img/no-notifications.svg');
但结果我进入了 dist 文件夹中的下一个文件:
but in result I got in dist folder next file:
no-notifications.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 配置中添加了一个新选项(因为 v7.2.1) 将css资源复制到另一个文件夹(相对于输出路径).
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屋!