SCSS模块出现流错误 [英] SCSS Modules Giving Flow error
本文介绍了SCSS模块出现流错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
已更新为 Create React App 2
,它通过以下导入语句支持css模块:
Updated to Create React App 2
which supports css modules via the following import statement:
import styles from "./myStyles.module.scss";
但是, flow
却在抱怨:
Importing from an untyped module makes it any and is not safe!
Did you mean to add // @flow to the top of ./myStyles.module.scss? (untyped-import)
这是我的 .flowconfig
文件中的 [options]
的样子:
This is what the [options]
in my .flowconfig
file looks like:
module.file_ext=.js
module.file_ext=.jsx
module.file_ext=.scss
我也尝试添加以下行:
module.file_ext=.module.scss
推荐答案
You probably want to use module.name_mapper.extension
to get it to map your SCSS files to some mocked module. (The flowtype docs even have an example for doing this same thing with .css files).
因此您可以使用以下配置:
So you might use this config:
module.name_mapper.extension='scss' -> '<PROJECT_ROOT>/SCSSFlowStub.js.flow'
以及SCSSFlowStub.js.flow
and in SCSSFlowStub.js.flow
export default Object;
这篇关于SCSS模块出现流错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文