admin管理员组文章数量:1355703
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
本文标签: javascriptWhat39s the best way to add add sassscss in a React appStack Overflow
版权声明:本文标题:javascript - What's the best way to add add sassscss in a React app? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1743948632a2566875.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论