【问题标题】:How can I tell React Native's *Metro Bundler* to serve files from `./lib/src`?如何告诉 React Native 的 *Metro Bundler* 从 `./lib/src` 提供文件?
【发布时间】:2018-01-24 08:23:58
【问题描述】:

我正在开发一个 React Native 项目。我的 TypeScript 文件位于 ./src。这被转译为./lib/

例如 ./src/index.ts./lib/src/index.js 结尾。

我如何告诉 Metro Bundler (npm start) 提供来自 ./lib/src 的文件?

【问题讨论】:

    标签: typescript react-native


    【解决方案1】:

    我想通了。

    android/app/build.gradle

    更改第 5 行

      1 apply plugin: "com.android.application"
      2
      3 import com.android.build.OutputFile
      4
      5 project.ext.react = [
      6   entryFile: "src/index.js"
      7 ]
      8
    

    【讨论】:

      【解决方案2】:

      嗯,这有点晚了......但你可能想要做的是:

      1. 将您的 ./index.js 更改为 import "./lib
      2. 将您的 tsconfig.json outDir 属性更改为 "./lib"(这样可以避免使用 ./lib/src 路径。

      这就是我对我的项目所做的。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2020-01-03
        • 2019-01-30
        • 1970-01-01
        • 2021-02-26
        • 2020-03-15
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多