How to add SASS to a create-react-app Project?
Using SASS is one of the best ways of styling modern web applications. It essentially helps us write more maintainable and modular CSS code, but CRA doesn't support it out of the box. This article will help you do that.
TL;DR
- 
install node-sassas a dependency.
- 
change .cssto.scssor.sassfile extension.
- 
import the .scssor.sassfiles instead of.cssfiles inside the components.
- 
Adding node-sass To get started with SASS in React we first have to install an npm package node-sassin our react app.
npm i node-sass
or, if you're using yarn
yarn add node-sass
- Changing file extensions
Now, change the .cssfile extension to.scss.
Note that SASS offers two syntaxes, one is
.scsswhich we are going to use and the other is.sasswhich is known as the indented syntax. The.sassfiles differ in the indentation it uses instead of curly braces and semicolons.
- Changing imports
Change the imports in your components to .scssinstead of.css
And we are ready to use SASS in our app.