简体   繁体   English

使用typescript将sass加载到create-react-app中

[英]loading sass in a create-react-app with typescript

I recently migrated a create-react-app to typescript. 我最近将create-react-app迁移到打字稿。 After migration my scss files are being ignored in the .tsx components. 迁移后,.tsx组件中的scss文件将被忽略。 I'm importing the files like so: 我正在这样导入文件:

import './styles/scss/style.scss';

this was working fine in js. 这在js中工作正常。 I've already installed node-sass and even tried installing @types/node-sass. 我已经安装了node-sass,甚至尝试安装@ types / node-sass。 I'd like to do this without ejecting. 我想这样做而不弹出。 Would appreciate any help. 将不胜感激。

According with this documentation https://facebook.github.io/create-react-app/docs/adding-a-sass-stylesheet#docsNav 根据此文档https://facebook.github.io/create-react-app/docs/adding-a-sass-stylesheet#docsNav

If you use react-scripts@2.0.0 or higher just 如果您使用react-scripts@2.0.0或更高版本

npm install node-sass

restart and enjoy. 重新启动并享受。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM