我有一个 Angular 解决方案,我想将一个 config.json 文件导入到“styles.css”文件中。 我什至不知道这是否可能,因为我没有通过搜索类似问题找到类似的东西。
config.json 文件如下所示:
{
"style" : {
"primaryColor": "#008080",
"secondaryColor" : "#D32F2F"
}
}
这是 styles.css 的样子:
import * as config from 'config.json';
html {
font-family: 'Trebuchet MS';
background-color: '$config.style.primaryColor';
}
如您所料,这甚至无法编译。但我希望你们明白我想做什么。您知道如何实现吗?
最佳答案
如果您使用的是 Angular,您可以使用 scss
和 node-sass-json-importer 来完成,就像描述的那样 here .
关于css - 将 JSON 配置文件导入 styles.css,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57890450/