I am basically making a small design library using bootstrap 5 and Angular. I am using boostrap core, add some extension or custom style to it (to fit my design).
Basically, I use bootstrap as follow :
LIBRARY :
I have 2 scss in my library :
design-library.core.scss
// Required to be imported for bootstrap
@import '~bootstrap/scss/functions';
// Library default variable that override bootstraps one
@import './variables';
design-library.extension.scss
// I need to import the variables or they are undefined
@import './variables'
// some override of bootstrap style like
.alert {
background: $white;
}
PROJECT :
Now, In my project, I use the design-library as follow :
project.scss
// Import the default variable of the libraryu
@import '~/design-library.core';
// override the default with additional variables
@import './project-variables'
// import bootstrap
@import '~bootstrap';
// import the extension of bootstrap from the library
@import '~/design-library.extension'
This works great, the problem I have tho, is with variables overrides.
Let's say I put $red: #f00 as default in the library.
Then, In the project variables I set $red: #e30000
In my library extension when import variables, I import the one of the library (since I can't import the one of the project of course...). But since I import the one from the Library (and not the override one), all my CSS will be generated with $red: #f00. I want instead all my extension css to use overridden variable so it should be $red: #e30000
How can I import variable after they have been overridden by the project that implements them ?
EDIT : Is this clear enough ? :x