简体   繁体   English

将自定义样式表导入create-react-app的app.scss

[英]Import custom stylesheets into create-react-app's app.scss

I am new to styling using app.scss for a new create-react-app and would like to know the following: 我是使用app.scss进行新的create-react-app造型的新手,并且想了解以下内容:

  1. Should i store all the .scss and .css files in the style folder? 是否应将所有.scss和.css文件存储在样式文件夹中?
  2. If I would like to import all of them into the app.scss, how do I go about doing that? 如果我想将所有这些导入到app.scss中,该如何做呢?

I noticed that app.scss does these: 我注意到app.scss可以做到这些:

  1. @import '~bootstrap/scss/bootstrap'
  2. $fa-font-path: '~@fortawesome/fontawesome-free/webfonts'

When i tried to do this: @import './myStyles.css' it does not get picked up. 当我尝试执行此操作时: @import './myStyles.css'不会被拾取。 I am not sure what is going on. 我不确定发生了什么。

The reason i am adament about putting it in the app.scss file is becauase i created a toggle that allows me to switch between dark and light theme. 我之所以喜欢将其放入app.scss文件,是因为我创建了一个切换开关,该开关可以让我在深色和浅色主题之间切换。 However, I am unable to add customed theme to the existing themes. 但是,我无法将自定义主题添加到现有主题。

Hope my question is clear 希望我的问题清楚

Here is reply for you query- 这是您的查询答复-

1.Should i store all the .scss and .css files in the style folder? 1.是否应将所有.scss和.css文件存储在样式文件夹中? - for this you have to make two folder, one is css and another sass(better approach) -为此,您必须制作两个文件夹,一个是css,另一个是sass(更好的方法)

2.If I would like to import all of them into the app.scss, how do I go about doing that?- "@import 'reset';" 2.如果我想将所有这些都导入到app.scss中,该如何做呢?-“ @import'reset';” no need of scss extension 无需scss扩展

If you are working on big project then i would suggest you that better follow this structure. 如果您正在从事大型项目,那么我建议您更好地遵循此结构。

inside sass or scss folder make subfolder for diffrent works like vendor, module,particles etc. like modules/_colors.scss and follow below structure 在sass或scss文件夹中,使子文件夹可以处理不同的工作,例如供应商,模块,粒子等,例如modules / _colors.scss并遵循以下结构

// Modules and Variables //模块和变量

@import "partials/base"; @import“ partials / base”; @import "partials/buttons"; @import“部分/按钮”;

I hope this will help. 我希望这将有所帮助。

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

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