Instead of modifying the source files located in node_modules\bootstrap\scss
, a better approach would be to create your own .scss
stylesheet with the variables that you might want to override.
For example, if you're overriding these two variables from Bootstrap’s default configuration:
$primary;
$success;
Create a sass file. For the purposes of this example, we will create ours at src/assets/scss/main.scss
Declare your new variables
$primary: #5f5ca3;
$success: #4ebc94;
Lastly, and most crucial, import the main.scss class you just created. Make sure you do it before you import the Bootstrap stylesheets.
It might seem counterintuitive to import variable overrides before importing the variables themselves, but that's what you need to do here.
If you look at that _variables.scss file(node_modules/bootstrap/scss/_variables.scss
), you'll see that plenty of the variable definitions are followed by !default
.
That's the SCSS way of saying: "If this variable isn't already defined, then define it here."
But you already defined those two variables yourself. So they won't get redefined.
So your src/styles.scss
should look something like this:
/* importing KOR theme */
@import './assets/scss/main;
/* Importing Bootstrap SCSS file. */
@import '~bootstrap/scss/bootstrap';
// other style declarations and global configurations
I hope this helps! Here's the documentation from the Bootstrap team.