B
B
bloh_creator2021-09-29 20:59:49
JavaScript
bloh_creator, 2021-09-29 20:59:49

How to change css file with node js?

Good day. There was a question related to changing the css file using node js. Currently under development with components. React in conjunction with popular libs and the question arose about changing the font in the component, for example. There must be a component that takes in a certain coefficient by which all styles that are attached to this component are multiplied. Styles are connected as modules (example ->"import styles from './styles.module.css'" ) into a component and we need the ability to rebuild this css. In fact, there is something in my head, take css to parse it somehow, find the keywords by which you can pull out the property, multiply it by a coefficient and put it back into the file. Any ideas about this? Assumptions? Ready options? I will be glad to help.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Rsa97, 2021-09-29
@Rsa97

Try CSS variables.

body {
  --font-multiplier: 1.2;
}

h1 {
  font-size: calc(var(--font-multiplier) * 2em);
}

h2 {
  font-size: calc(var(--font-multiplier) * 1em);
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question