Each import of SCSS file in JS file is treated as an isolated SASS env, therefore, there is no such thing "global variables" while using SCSS in React. This behavior requires us to import the variables.scss file into each SCSS file that uses one of the variables.
_variables.scss
$global-font : "Cairo", sans-serif;
$global-background: whitesmoke;
App.js
import './App.scss'
export function App()
{
return (
<div className="App"></div>
)
}
App.scss
@import "variables.scss";
.App {
background-color: $global-background;
font-family: $global-font;
// ...
}
Header.js
import './Header.scss'
export function Header()
{
return (
<div className="Header"></div>
)
}
Header.scss
@import "variables.scss";
.Header {
background-color: $global-background;
font-family: $global-font;
// ...
}
I have to import the _variables.scss file to multiple (maybe 100+) other SCSS files to make use of the variables. Does doing this increase bundle size?
P.S. The variables.scss file contains only SCSS variables and nothing else.