【问题标题】:SCSS Modules Giving Flow errorSCSS 模块给出流量错误
【发布时间】:2018-10-07 19:10:41
【问题描述】:

更新到Create React App 2,通过以下导入语句支持css模块:

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] 的样子:

module.file_ext=.js
module.file_ext=.jsx
module.file_ext=.scss

我也尝试添加以下行:

module.file_ext=.module.scss

【问题讨论】:

  • 我认为您根本不希望 flow 处理 .scss 文件。如果您删除 .scss 的 module.file_ext 设置,您会得到什么?
  • @DaveMeehan 删除该行时,我收到大量流程错误,提示我的所有 scss 文件“无法解析模块”

标签: css reactjs sass flowtype


【解决方案1】:

您可能希望使用module.name_mapper.extension 将您的 SCSS 文件映射到某个模拟模块。 (flowtype 文档甚至有一个使用 .css 文件做同样事情的例子)。

所以你可以使用这个配置:

module.name_mapper.extension='scss' -> '<PROJECT_ROOT>/SCSSFlowStub.js.flow'

在 SCSSFlowStub.js.flow 中

export default Object;

【讨论】:

  • 执行此操作并运行流程可以消除与我的 xxx.module.scss 导入相关的错误,但会在我的旧版 xxx.scss 导入中出现新错误,例如 cannot resolve module FILE_PATH/SCSSFlowStub.js
  • 您确定路径正确吗?使用 和一切?
猜你喜欢
  • 2012-04-01
  • 2017-09-08
  • 1970-01-01
  • 2017-05-15
  • 2016-09-09
  • 2022-11-08
  • 2014-01-29
  • 1970-01-01
  • 2021-09-25
相关资源
最近更新 更多