盖茨比的全球scss [英] global scss in Gatsby
问题描述
我刚开始使用盖茨比.
在我正常的react-project中,我通常有一个 common.scss
文件.该文件包含我可能经常使用的类名
In my normal react-project, I generally have a common.scss
file. This file contains classes name which I may use frequently
例如
.row {
display: flex
flex-direction: row
}
在React应用程序中,我将其导入到 index.js
中.我可以将其导入屏幕文件夹内的所有文件中,但是我在想是否有更好的方法?
In React app, I will just import it in the index.js
. I could just import it in all the files inside my screen folder but I was thinking if there is any better way?
推荐答案
在gatsby中,您可以在根目录中创建文件 gatsby-browser.js ,您可以在其中导入要成为全局样式的样式.
In gatsby you can create a file gatsby-browser.js in the root where you can import styles that you want to be global.
您可以在其中放置类似的内容以导入样式
There you can put something like this to import the style
import 'pathtoyourcssfile.css';
更多详细信息可以在这里找到:
More details can be found here:
https://www.gatsbyjs.org/docs/global-css/#adding-global-styles-without-a-layout-component
这篇关于盖茨比的全球scss的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!