Reputation: 151
I have an Angular solution, and I would like to import a config.json file into the "styles.css" file. I don't even know if that is possible, because I did not find anything like this by searching for similar issues.
Here's what the config.json file looks like:
{
"style" : {
"primaryColor": "#008080",
"secondaryColor" : "#D32F2F"
}
}
Here's what the styles.css looks like:
import * as config from 'config.json';
html {
font-family: 'Trebuchet MS';
background-color: '$config.style.primaryColor';
}
As you can guess, this does not even compile. But I hope you guys get the idea of what I'm trying to do. Do you have any idea how to achieve that?
Upvotes: 0
Views: 4245
Reputation: 439
If you are using Angular, you can do it with scss
and node-sass-json-importer, like it is described here.
Upvotes: 1
Reputation: 10864
Potential Solution: You can convert your Angular application to support SASS and once you've completed that you can accomplish what you want by using the node-sass-json-importer
Upvotes: 0
Reputation: 2926
Unfortunately you can't do so.
You could use config in your component code and assign css from there. Like:
<div [style.width.px]="yourValueFromConfig">
where yourValueFromConfig
- variable in component assigned from config.
Upvotes: 0