[英]Seperate SCSS for different Angular modules
Is there any way to separate scss for separate modules. 有没有办法将scss分离为单独的模块。 In details if I have 2 modules called
module_1
and module_2
and 2 scss files called module_1.scss
and module_2.scss
. 详细说明如果我有2个模块名为
module_1
, module_2
和2个scss文件名为module_1.scss
和module_2.scss
。 I want my angular module_1 to load other scss except module_2.scss
and similarly for module_2 I don't want module_1.scss
to get loaded. 我希望我的角度module_1加载其他SCSS除了
module_2.scss
同样地,对于module_2我不想module_1.scss
得到加载。 How can I achieve this in angular. 我怎样才能在角度上实现这一目标。
Thanks in advance. 提前致谢。
Since angular has styles imported at the component level, you can create module_1.scss
and module_2.scss
-- and then for each container-level component in the modules, add the appropriate scss file to the styles array 由于angular具有在组件级别导入的样式,因此您可以创建
module_1.scss
和module_2.scss
- 然后对于模块中的每个容器级别组件,将相应的scss文件添加到样式数组
Example module_1 > component_foo 示例module_1> component_foo
@Component({
selector: 'app-foo',
templateUrl: './foo.component.html',
styleUrls: ['../module_1.scss']
})
Example module_2 > component_bar 示例module_2> component_bar
@Component({
selector: 'app-bar',
templateUrl: './bar.component.html',
styleUrls: ['../module_2.scss']
})
Because of this, I would recommend trying to group components into parent "containers" of other small/dumb child components so only the parent needs the styles imported 因此,我建议尝试将组件分组到其他小/哑子组件的父“容器”中,这样只有父组件需要导入的样式
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.