2 ms·
Css modules automate the process and it's totally OK approach, but with a bit of discipline imposed on the team members you can achieve the same effect manually
by ivanhoe 7y ago
Css modules automate the process and it's totally OK approach, but with a bit of discipline imposed on the team members you can achieve the same effect manually and avoid the weird looking foo_532xy157678 classes. You just need a proper selector naming convention in place, and then make everyone stick to it. It's not a rocket science really, you just add a unique class (usually module's name works just fine here) to every module's root element, and then in sass you wrap everything related to that module with that class and that's it, it's namespaced... add some BEM to the mix and you've got yourself fairly easy to understand and maintain sass/css with zero overhead... obviously takes some practice to unlearn yourself from using overly general selectors, but it's like learning to write testable code, you quickly learn to pay attention to bad practices...