At work, I've been using SCSS for a few years. I've now just started my own React project and want to use it as well. To this end I installed dart-sass. I prefer building React component "bundles" where a folder with the same name as the component (ex. Button) contains the following files:
- Button.tsx (the component, written in TypeScript)
- Button.module.scss
- Button.test.ts
- Button.md
The main point here is that I mostly prefer the *.module.scss approach because it keeps the styles isolated.
However, I realize that there will be occasions for global styles. To this end, I've created a sass/styles.scss file into which I can import partial style files like _variables.scss, _fonts.scss, etc.
What I'm unclear on is where should I best be importing styles.scss? The highest level files, index.tsx or App.tsx seem like candidates but I'm hoping that the community could give me some best practice tips on this. Thank you.