gpt4 book ai didi

javascript - 可以把scss改成json吗?

转载 作者:行者123 更新时间:2023-12-03 03:33:05 24 4
gpt4 key购买 nike

我想将带有变量的 scss 文件转换为 json 文件。但我不知道这是否可能。有人可以给我一些建议吗?

所以我想将这种scss文件转换为json文件,变量在其他文件中定义:

.test {
color: $test1; //#000000
}
.test1 {
color: $test2; //#ffffff
}

输出应如下所示:

{
".test":{
"color":"#000000"
},
".test1":{
"color":"#ffffff"
}
}

最佳答案

当然可以。

请检查此包:https://github.com/ryanbahniuk/scss-to-json

输入:

// Font Sizes
$font-size: 14px;
$font-size-large: $font-size * 1.1;

// Colors
$text-color: #666;
$text-color-light: lighten($text-color, 15%);
$border-color: #123 !global; // use for all borders

输出:

{
"$font-size": "14px",
"$font-size-large": "15.4px",
"$text-color": "#666",
"$text-color-light": "#8c8c8c",
"$border-color": "#123"
}

来源scss to json github

关于javascript - 可以把scss改成json吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45995966/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com