admin管理员组文章数量:1122826
We have to use a library with some css that looks like this. Until now we imported it with @import
, but we'd like to update to @use
.
.esri-view {
...
font-family: $font-family;
The $font-family
variable doesn't have a default value. Because of this, our @use
doesn't work:
@use '@arcgis/core/assets/esri/themes/base/_View.scss' with (
$font-family: var(--our-internal-font-family)
);
The error:
✘ [ERROR] Undefined variable. font-family: $font-family;
This would be easily fixable with a $font-family: somefont !default;
in the library's code (as per the sass docs) but as the css is loaded from npm we can't/don't want to change it.
Are there any feasible workarounds for this?
Context: We use this in an Angular 18 setup.
We have to use a library with some css that looks like this. Until now we imported it with @import
, but we'd like to update to @use
.
.esri-view {
...
font-family: $font-family;
The $font-family
variable doesn't have a default value. Because of this, our @use
doesn't work:
@use '@arcgis/core/assets/esri/themes/base/_View.scss' with (
$font-family: var(--our-internal-font-family)
);
The error:
✘ [ERROR] Undefined variable. font-family: $font-family;
This would be easily fixable with a $font-family: somefont !default;
in the library's code (as per the sass docs) but as the css is loaded from npm we can't/don't want to change it.
Are there any feasible workarounds for this?
Context: We use this in an Angular 18 setup.
Share Improve this question asked Nov 22, 2024 at 9:26 sandroocosandrooco 8,71511 gold badges55 silver badges97 bronze badges1 Answer
Reset to default 0You can create a custom wrapper Sass file that defines the $font-family variable before importing the library. For example:
// _custom-view.scss
$font-family: var(--our-internal-font-family);
@use '@arcgis/core/assets/esri/themes/base/_View.scss' with (
$font-family: $font-family
);
Then, import your custom wrapper file in your project:
@use './path/to/_custom-view';
This method works by ensuring the variable is already defined when the library's styles are loaded.
本文标签: cssHow can I assign a library39s sass variable without it having a default valueStack Overflow
版权声明:本文标题:css - How can I assign a library's sass variable without it having a !default value - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736304836a1932375.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论