Reputation: 2054
I was about to ask it here but I found an answer while looking at the similar questions it's listed, so I'll answer myself hopefully will help others 🙃
It's about using the !default
with SCSS.
A simple usage would be:
_define.scss:
$text-color: #1c1c1c !default;
$button-background-color: deepskyblue !default;
core.scss:
@import "define";
html, body
{
color: $text-color;
}
button.scss:
.button
{
background-color: $button-background-color;
}
button.tsx: (using css-modules-typescript-loader)
import style from "./button.scss";
const Button = () => (
<button className={style.button}></button>
);
_define_override.scss:
$text-color: #2c2c2c;
$button-background-color: tomato;
style.scss:
// Note that the override file is first.
@import "define_override";
@import "../Project A/core";
Now when using style.scss in Project B the _define_override.scss will override the text color of the Project A. But, it won't override the button's background color and this is because I'm using the css-modules.
Upvotes: 0
Views: 141
Reputation: 2054
I fixed it using sass-resources-loader where I created in Project B a file e.g. named _define.scss
which will have:
$text-color: #2c2c2c;
$button-background-color: tomato;
And added it to the loader:
{
loader: "sass-resources-loader",
options:
{
resources: path.resolve(PROJECT_ROOT, "src/theme/_define.scss")
}
}
Upvotes: 1