问题
So I successfully configure webpack for loading scss style that is in my components.
I use a <style lang="scss"></style> and it goes well.
I used the vue-cli with the webpack installation.
But I would need to call some of my scss variables from there, so I guess I would need a kind of preload?
Is there a way to do it without having to @import in each component?
回答1:
You need sass-resources-loader.
The solution is provided in vue-loader's official document. Please check the section named Loading a global settings file.
PS: Actually, it's been discussed as an issue for quite a while. You can check the discussion here.
来源:https://stackoverflow.com/questions/45544300/how-to-preload-variables-in-a-component-style