[英]SASS: imported scss in index.js not rendering (using create-react-app)
I'm working on a create-react-app project, which I hooked SASS to, using these instructions: https://github.com/facebook/create-react-app 我正在使用一个create-react-app项目,使用以下说明将SASS连接到该项目: https : //github.com/facebook/create-react-app
Then, in my source, I created a style folder with a partials folder and an index.scss. 然后,在我的源代码中,我创建了一个样式文件夹,其中包含一个partials文件夹和一个index.scss。 Inside the partials folder, I have a firstComponent.scss file.
在partials文件夹中,我有一个firstComponent.scss文件。 I imported the scss from the firstComponent file into my index.scss.
我将scss从firstComponent文件导入到index.scss中。 The styles are being successfully imported into my index.css file.
样式已成功导入到我的index.css文件中。 However, they are not being rendered on the browser.
但是,它们不会在浏览器上呈现。 Why is this?
为什么是这样?
here is my index.js 这是我的index.js
import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
import registerServiceWorker from './registerServiceWorker';
import './style/index.scss';
ReactDOM.render(<App />, document.getElementById('root'));
registerServiceWorker();
here is my index.scss 这是我的index.scss
@import './partials/_firstComponent';
body {
margin: 0;
padding: 0;
font-family: sans-serif;
}
here is my firstComponent.scss 这是我的firstComponent.scss
.firstComponent {
background-color: 'red';
}
here is my index.css 这是我的index.css
.firstComponent {
background-color: 'red'; }
body {
margin: 0;
padding: 0;
font-family: sans-serif; }
You will need this line instead 您将需要此行
require('./style/index.scss'); require('./ style / index.scss');
NOT 不
import './style/index.scss'; 导入'./style/index.scss';
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.