【问题标题】:Create-react-app doesn't support relay compiler's --artifactDirectory optionCreate-react-app 不支持中继编译器的 --artifactDirectory 选项
【发布时间】:2021-12-15 10:22:21
【问题描述】:

relay docs 中,他们会提示您为中继编译器使用--artifactDirectory 选项。这会导致所有生成的文件都放在一个目录中,这对我来说听起来是个好主意!然而,使用这个选项会导致一堆这样的错误:

Failed to compile

./src/path/to/component/Component.tsx
Module not found: Can't resolve './__generated__/Component_field.graphql' in '/Users/me/path/to/project/src/path/to/component'

如何在create-react-app 中使用relay-compiler--artifactDirectory 选项?

【问题讨论】:

    标签: create-react-app relayjs


    【解决方案1】:

    你不能。 babel-plugin-relay/macro(或babel-plugin-relay)需要配置相同的选项,否则它将在源文件旁边的./__generated__/目录中查找生成的文件。 this stackoverflow answer 中有关于如何执行此操作的说明,但 在 create-react-app 中无法配置 babel-plugin-macros

    【讨论】:

      猜你喜欢
      • 2017-06-10
      • 2019-04-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-07-30
      • 2017-08-06
      相关资源
      最近更新 更多