从 css 模块访问外部 scss 变量(react-create-app)

时间:2021-02-16 19:51:13

标签: reactjs webpack sass module react-create-app

有create-react-app (react 17),执行eject 来访问配置,有scss 模块index.module.scss,它使用colors.scss 文件中的$white 变量和颜色。该模块是隔离的,无法访问该变量。我找到的唯一解决方案是将 colors.scss 转换为一个模块并将其导入到每个使用颜色值变量的 scss 文件中。有没有办法让这些 scss 变量可用于所有文件而不进行这种复制?

Traceback (most recent call last):
  File "/home/coyote/anaconda3/envs/cwl/lib/python3.6/site-packages/cwltool/main.py", line 991, in main
    make_template(tool)
  File "/home/coyote/anaconda3/envs/cwl/lib/python3.6/site-packages/cwltool/main.py", line 744, in make_template
    generate_input_template(tool),
  File "/home/coyote/anaconda3/envs/cwl/lib/python3.6/site-packages/cwltool/main.py", line 301, in generate_input_template
    template.insert(0, name, value, comment)
  File "/home/coyote/anaconda3/envs/cwl/lib/python3.6/site-packages/ruamel/yaml/comments.py", line 722, in insert
    self.yaml_add_eol_comment(comment, key=key)
  File "/home/coyote/anaconda3/envs/cwl/lib/python3.6/site-packages/ruamel/yaml/comments.py", line 295, in yaml_add_eol_comment
    if comment[0] != '#':
IndexError: string index out of range

我在这里找到了一个旧的解决方案,这是我的一对一情况,仅在 React 中,但我无法在配置中编写它以使其正常工作(如果我理解正确,在 ./config/webpack.config. js),也许有人可以帮忙

Using SCSS variables in CSS Modules

0 个答案:

没有答案
相关问题