[英]Angular assets building in /dist folder
I am using the flag-icon-css package that supplies you a css "font" file and all SVGs of flags.我正在使用 flag-icon-css 包,它为您提供一个 css“字体”文件和所有标志的 SVG。 There was an issue with the package (4x3 flags not showing properly), so I pulled all of the files out of node_modules
and fixed the issue.包存在问题(4x3 标志未正确显示),因此我从node_modules
提取了所有文件并修复了该问题。
I now have all of the css and flag icons under the src/assets/fonts
folder.我现在在src/assets/fonts
文件夹下有所有的 css 和标志图标。 I updated my angular.json
to reflect the changes and made sure the flag-icon-css
folder in node_modules
was deleted, but the flag icons are still saving in both the /dist
and also assets/fonts
folder.我更新了我的angular.json
以反映更改,并确保该flag-icon-css
文件夹node_modules
已被删除,但旗上的图标都仍然保存/dist
,也assets/fonts
文件夹中。
Here is what my angular.json
was changed to:这是我的angular.json
更改为:
"styles": [
"src/assets/fonts/flags/flag-icon.min.css",
"src/styles.scss"
],
"assets": [
"src/favicon.png",
"src/assets",
],
I even tried adding the full path: src/assets/fonts/flags/icons
, but it still builds them directly into the dist
folder.我什至尝试添加完整路径: src/assets/fonts/flags/icons
,但它仍然将它们直接构建到dist
文件夹中。
All files added to "styles": []
are always moved to the top level of the root ' /dist
' when builded.添加到"styles": []
所有文件在构建时总是移动到根 ' /dist
' 的顶层。 This is because they're global files.这是因为它们是全局文件。 More info here under "styles".更多信息在这里下的“风格”。
You have multiple options to solve your problem:您有多种选择来解决您的问题:
Remove the "src/assets/fonts/flags/flag-icon.min.css" from the "styles": [..]
array.从"styles": [..]
数组中删除 "src/assets/fonts/flags/flag-icon.min.css"。
Import it into your styles.scss
like:将它导入你的styles.scss
如:
@import('path/outside/assets/flag-icon.min.css')
Now they should be included in your /dist/styles.css
after build.现在它们应该在构建后包含在您的/dist/styles.css
。 If you keep the icons inside the assets folder they will be imported to the styles.css
and /dist/assets/..
folder如果您将图标保留在assets 文件夹中,它们将被导入到styles.css
和/dist/assets/..
文件夹中
Import the icon set from your index.html
从index.html
导入图标集
<link href="assets/fonts/flags/flag-icon.min.css" rel="stylesheet">
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.