I'm gonna assume you've got one master import file, with something like:
@import 'variables'
@import 'base'
@import 'some_component'
@import 'some_other_component'
The reason your variables are available to your other stylesheets is that the imports cascade. So, as soon as you import variables, everything imported after is in the same scope as those variables (as they've been imported).
This can be a blessing and a curse, as any variables you define outside of block scope in any of your other stylesheets will also become globally available to all stylesheets imported after that one.
Because of this, it's generally considered best practice to import all variables that are to be global at the very top of your main import stylesheet, and then block-scope any local variables that you don't want to expose globally, like so:
.SomeComponent {
$height: 100px; // this is only accessible from within this block, and children of this block;
.SomeComponent-child {
height: $height;
}
}
Conversely, a variable defined in _variables.scss will be available everywhere, so you could also do:
.SomeComponent {
$height: $global-height; // `$global-height` defined in `_variables.scss`
.SomeComponent-child {
height: $height;
}
}