D
D
devilsD2018-06-19 21:40:54
Sass
devilsD, 2018-06-19 21:40:54

How to use SASS mixins and variables in all Vue components?

If I include global styles in the component:

<style lang="scss">
@import "./sass/main.scss";
.bs-navbar-nav{
    background-color: $bg_color; /*переменная из main.scss */
}
</style>

In this case, I can use the $bg_color variable or mixins from the imported file, but I can't use the variable in another component without re-importing it. Is it possible to include main.scss globally so that the variables are available in any component?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Evgeny Kulakov, 2018-06-19
@kulakoff Vue.js

This can be done via webpack and the sass-resource-loader plugin. Pass a file with variables into it, as a result they will be available everywhere.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question