
Stefan R. answered 02/06/20
Senior Full Stack Developer Delivering Web Applications for 10+ Years
This is a loaded question as it highly depends on how your code-base is structured and organized.
In general, precompilers are used in order to "string together" files accordingly.
I recommend looking into something like Sass to get an introduction to the concepts. Basically, the most common solution is to have one CSS file which is a result of operations such as importing files and interpreting variables and functions (often referred to as mixins in this context).
An easy example:
main.scss
theme.scss
buttons.scss
Pitfalls:
- Watch out for the correct order of importing
- Watch out for the difference of scss and sass files
- Watch out for differences in compilers (ruby, lib, dart)
Final note:
In more complex scenarios, compilation of CSS goes through other dynamic processes first. Looking into concepts like postCSS or webpack might give you some insight into what's possible, once you are comfortable with the general approach.