如何设置index.scss并将变量,mixins等的全局样式表导入角度6库?
Angular CLI生成具有根组件和组件scss的lib,但添加或导入到根组件的样式不可用于子组件.默认情况下,封装样式是有道理的,但我找不到任何关于如何设置它的信息或示例.
"styles": [...]可以用于此的angular.json 路径"projectType": "application"似乎"projectType": "library"也不适用.
在此先感谢您的帮助!
更新:我的项目是使用angular cli v6.0.5启动的,遵循本指南:https://medium.com/@tomsu/how-to-build-a-library-for-angular-apps-4f9b38b0ed11
TL; DR指南:
ng new my-app --style=scss
ng generate library my-library --prefix ml
Run Code Online (Sandbox Code Playgroud)
这是angular 6生成的文件结构:
my-app
projects/
my-library/
src/
lib/
shared/..
widgets/..
my-library.component.ts
my-library.module.ts
sass/
_variables.scss
styles.scss // <<< This is where I want to `@import 'variables';`, and for it to be available in all the components of the "my-library" project.
public_api.ts
src/
app/
app.module.ts // << imports projects/my-library/lib/my-library.module as "my-library".
main.ts …Run Code Online (Sandbox Code Playgroud)