I recently inherited an existing web application built in ReactJS. I'm not an expert in either React or SASS, but as best I can tell, this app handles styling by...
Having a bunch of small .scss files, split up logically by things like color variables, font faces, button styling, etc.
Importing all of those into one big app.scss file.
Importing that into the index.jsx of the React app.
I've confirmed that changes to the partial files correctly cascade throughout the whole app.
Now, my employer wants to implemented white-labeling of this application, and part of that means letting our customers change certain things in the stylesheet, such as colors. My instinct is that I could, for example, create a new partial scss file for each of our customers, with different values for the color variables, and load this instead of the default _colors.scss that always gets loaded at the moment.
However, given the import flow, I'm not sure this is possible. I won't actually know which customer is using the app until the app has loaded and called the server--meaning the SASS has already been compiled and served, so it's much too late to intercept the imports during React compilation.
Am I understanding correctly, and if so, is there a best practice or "SASS way" for switching or overwriting stylesheets dynamically? Could React import a new stylesheet, or even recompile the SASS while running?
Off the top of my head, all I can think to do is load a new stylesheet from the server with selectors for every element that needs its styling overwritten, and that would be extremely fragile (and probably loaded with !important). I would love to find a cleaner way to do this.
Ninja Edit: I suppose I could also pull the changeable styles out of the SASS environment into their own stylesheet and do something like this: Dynamically load a stylesheet with React. But I think that would be a mess, as I would be abandoning SASS's ability to define variables, and the color variables (for example) are everywhere.
Thanks so much for any advice or guidance! Let me know if I can provide any more information.