How to pre-load SASS custom utilities (variables a

2019-07-17 07:20发布

I am loading my utilities and assets in base.scss like so

@import "_variables";
@import "_mixins";
...

I have tons of modules in my application and we are doing so many changes in these modules.
so importing the base.scss in the header of each of the scss files is causing so much trouble and seems very redundant.

I tried using sass's includePaths but it didn't help as it only resolves the @import declarations.

Is there any way that I can auto import my utilities without having to @import it manually in each file?

1条回答
来,给爷笑一个
2楼-- · 2019-07-17 07:38

This loader will do the job
https://github.com/shakacode/sass-resources-loader
by adding this to your webpack config

sassResources: [ './path/to/vars.scss', './path/to/mixins.scss' ]

Update

check the implementation out in action in this boilerplate

查看更多
登录 后发表回答