我尝试以下成功(使用纯HTML和
Scout-App将SCSS转换为CSS):
编辑:如前所述,我从未使用过React,但是基于这个帖子hugogiraudel.com,它应该与我的解决方案(或多或少/一见钟情)相同.
编辑2:我刚刚在几天前开始使用SCSS.据我所知,我唯一的错误就是我的例子中显示的打字错误.由于应用了“body”,所以假定您的组件中的import语句对于React是正确的.
如果有更好的解决方案,导入到组件必须由别人回答.但是,看起来链接博客文章的作者有另一种方法,还有一个github可用库.
目录结构:
- project_folder
- index.html
- stylesheets
- main.scss
- partials
- _all.scss
- _Home.scss
的index.html
样式表/ main.scss
@import 'partials/all'; // Your missing here a semicolon (;) I think
html { font-family: 'Roboto', sans-serif; }
body {
margin: 0;
background-color: orange; // here too but wasn't crucial
}
样式表/分音/ _all.scss
@import '_Home.scss';
样式表/分音/ _Home.scss
.headerStyle {
color: pink;
font-size: 30px; // I added here pixels because Firefox ignored it otherwise
font-weight: 500;
}