I want to use the css variable that is in an scss file from an installed module in node_modules.
node_modules folder:
|node_modules
- A
-- A1
--- variable.scss
varibale.scss:
$include-html-classes: false;
$include-html-global-classes: false;
@import "~foundation-sites/scss/foundation/components/_global.scss";
$default-color-white: #fff;
$color-white: var(--a-palette-complementary-0, $default-color-white);
webpack.config.js
{
test: /\.scss$/,
use: [
{
loader: MiniCssExtractPlugin.loader,
options: {
hmr: isDevelopment
}
},
{
loader: 'css-loader',
options: {
sourceMap: true
}
},
{
loader: 'postcss-loader',
options: {
plugins: [
require('autoprefixer')()
],
sourceMap: true
}
},
{
loader: 'sass-loader',
options: {
sassOptions: {
includePaths: [
path.resolve(__dirname, 'node_modules'),
path.resolve(__dirname, 'node_modules/foundation-sites/scss')
]
},
sourceMap: true
}
}
]
},
{
test: /\.css$/,
use: [
{
loader: MiniCssExtractPlugin.loader,
options: {
hmr: isDevelopment
}
},
{
loader: 'css-loader',
options: {
sourceMap: true
}
}
]
},
I got a compile error:
SassError: argument `$color` of `transparentize($color, $amount)` must be a color
But compile successful if I try to use the variable $default-color-white instead of $color-white
my scss file:
@import "~A/A1/variable";
.import-section {
border: 1px solid transparentize($color-white, 0.5); // compile error
}
@import "~A/A1/variable";
.import-section {
border: 1px solid transparentize($default-color-white, 0.5); // compile OK
}
I don't know why I can't use the variable that uses the var function. Am I doing the wrong CSS loaders config?