I found the create-react-app docs remends to use node-sass but the package in npm is saying that LibSass and Node Sass are deprecated. So if any one can help what's the best way to install sass in a React project?
I found the create-react-app docs remends to use node-sass but the package in npm is saying that LibSass and Node Sass are deprecated. So if any one can help what's the best way to install sass in a React project?
Share Improve this question edited Feb 19, 2022 at 8:23 Youssouf Oumar 46.6k16 gold badges103 silver badges105 bronze badges asked Dec 5, 2021 at 7:38 Mahmoud AbdulmutyMahmoud Abdulmuty 3586 silver badges15 bronze badges2 Answers
Reset to default 6I have been using it in my React applications by doing as Create React App's doc remends, and everything works fine. All you need is:
- First open your project terminal, stop your development server and run:
npm install sass
- Change your
.css
files to.scss
and updates your imports:
import './index.scss';
- Restart your development server and you are good to go:
npm start
this seem to work for me
npm install sass
page-heading.scss
.page-heading {
border: 3px solid red;
width: 100%;
&__divider {
border: 3px solid blue;
}
}
PageHeading.js
import { Typography, Divider } from '@mui/material';
import 'ponents/page-heading/page-heading.scss';
function PageTitle({ props: pageHeading }) {
console.log(pageHeading);
return (
<Typography ponent="h1" variant="h2" className="page-heading">
<Divider
sx={{
hyphens: 'auto',
whiteSpace: 'normal',
}}
className="page-heading__divider"
>
{pageHeading}
</Divider>
</Typography>
);
}
export default PageTitle;
https://www.npmjs./package/sass