block editor – Dynamically write gutenberg classes to css file

So i am creating a custom gutenberg and currently i have build it using the color theme from the brand so is used thr getColorClassName to generate the css class for when a color is added to the gutenberg.

I have the theme css with root variables

:root {
    --colorRed: #dd0d0d;
    --colorWhite: #fff;
}

I passed a gutenbergTheme attribute that is set by the PanelColorSetting in Inspector control and then generate a className with getColorClassName('color', attribute) and then a class is generated like .has-white-color for example.

I then manually write the styling for this class in the theme css like

.has-white-color {
    color: var(--colorWhite);
}

This works but not good enough in the sense that a change can require me to change multiple files.

The question is, is there a way to dynamically generate the css classes in the gutenberg.php file and then write those classes to the css file when the gutenberg is used?