简体   繁体   English

如何从角度lib中正确导入样式

[英]How to correctly import styles from an angular lib

In my current project I want to create a lib container all different styles ( scss-files ). 在我当前的项目中,我想创建一个所有不同样式( scss-files )的lib容器。 Therefore I need to import them into different components, so that the style will be set through these lib-scss files. 因此我需要将它们导入到不同的组件中,以便通过这些lib-scss文件设置样式。

Importing libs into modules is quite easy by @[projecttitle]/[libtitle] @[projecttitle]/[libtitle]将libs导入模块非常简单

But how can I import only stylesheets? 但是如何只导入样式表呢? Something like @import '~@[project]/theme/theme-to-import.scss'; @import '~@[project]/theme/theme-to-import.scss'; Does not seem to work. 似乎没有用。

I already tried importing like mentioned above, but that does not work at all. 我已经尝试过如上所述的导入,但这根本不起作用。

Workaround right now is taking the relative path, but I think that won't work well in production mode. 现在的解决方法是采取相对路径,但我认为这在生产模式下不会很好。

you need to put in angular.json 你需要放入angular.json

"styles":[
[project]/theme/theme-to-import.scss'
]

Put the correct path according to project folder. 根据项目文件夹放置正确的路径。

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

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