I create react app with create-react-app and setup the file structure like that:
src/
-index.js
-main.scss
pages/
-somepage.js
-somepage.scss
styles/
-_variables.scss
index.js
import './main.scss';
...
main.scss
@import './styles/variables.scss';
_variables.scss
$primary: #000;
somepage.js
import somepage.scss
somepage.scss
selector {
property: $primary; <-- sass can't find that
}
Any ideas please? Thank you.
@import './styles/variables';
@import './pages/somepage';
You could import all stylesheets in your main.scss and then all you need is import './main.scss';
in index.js . You also don't have to to specify the suffix.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.