Currently, I am utilizing the react boilerplate for my project. This boilerplate makes use of CSS Modules and postCSS for styling, which I find to be quite beneficial. However, I also require some global CSS files for typography, base components, and more. What would be the most recommended approach for incorporating these global styles? I have considered using preCSS, but I am unsure about the setup process in webpack to import these global files into the main stylesheet. My background is more Gulp/Grunt based and I work with Sass, so I am relatively new to webpack. Any guidance in this regard would be highly appreciated.
Additionally, it would be advantageous if I could utilize the variables and mixins defined in these global files within the CSS module files. Is this even feasible or advisable? To facilitate this, I have installed react-css-modules so that I can make use of styleName
for referring to the CSS Module file and className
for accessing the global CSS classes.
I am aware of the
composes: class from '/path/to/file.css';
attribute, but I would prefer having specific global files where utility classes like clearfix
and error classes are defined. By employing react-css-modules
, the implementation might look something similar to the following:
<div className="clearfix" styleName="app-header">{...}</div>
However, I am uncertain if this is the correct approach. As I am contributing to an open-source project, I strive to adhere to best practices and ensure that the implementation is of the highest standard possible. I appreciate any advice provided on this matter! Thank you.