How to pre-load SASS custom utilities (variables and mixins) with webpack

♀尐吖头ヾ 提交于 2019-12-11 00:22:29

问题


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:


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



来源:https://stackoverflow.com/questions/38456985/how-to-pre-load-sass-custom-utilities-variables-and-mixins-with-webpack

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!