I am using Vueify with Laravel/Elixir. I use Sass inside my Post.vue
file but it references colors I declare in @import "resources/assets/sass/bootstrap-variables-override.scss";
Is there a way to not have to include that line inside of every single .vue
component I make?
Asked
Active
Viewed 7,064 times
12

Brynn Bateman
- 769
- 1
- 8
- 22
-
5I don't know of anyway with browserify. But with webpack you can simple use this loader: https://github.com/shakacode/sass-resources-loader and make sure to use ` – meo Jan 31 '16 at 15:38
3 Answers
6
There's a discussion on the official vue-loader repo with the exact same question and it boils down to: no, you have to import the variables file in each .vue
component that needs it.
One thing you can do to simplify the situation slightly is to add the folder with the variables file to your include paths, so you can just do @import "my-variables.scss";
instead of specifying the entire path every time.

mzgajner
- 2,250
- 1
- 17
- 14
2
you can archive this by importing this in you top level component, usually called <app></app>
and expose it by using a css class:
.primaryColor {
color: <variable here>
}
Then you can just access that class in every child component

Alexander Meesters
- 380
- 2
- 12
0
Not always applicable but if you're using Vue as part of a Nuxt application then you can use style-resources-module to achieve this.

Brady Dowling
- 4,920
- 3
- 32
- 62