【问题标题】:React native run-ios run-android entry filereact native run-ios run-android 入口文件
【发布时间】:2017-02-09 19:25:12
【问题描述】:

我知道在react-native bundle 命令中,您可以使用--entry-file 标志将您的应用程序与指定的条目文件捆绑在一起。 react-native run-iosreact-native run-android 命令是否有类似的标志或解决方法,您可以在其中指定入口文件?

【问题讨论】:

  • 您可以简单地在这两个文件中导入您的文件

标签: react-native react-native-android react-native-ios


【解决方案1】:

react-native run-android --help 显示了一些选项,但没有指定入口点。但是在android/app/build.gradle 你会发现:

project.ext.react = [
    bundleAssetName: "index.android.bundle",
    entryFile: "index.android.js",
    bundleInRelease: true,
    jsBundleDirRelease: "$buildDir/intermediates/assets/release",
    resourcesDirRelease: "$buildDir/intermediates/res/merged/release"
]

然后您可以在 gradle build 中创建不同的变体

buildTypes {
    customVariant {
        minifyEnabled enableProguardInReleaseBuilds
        proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
        debuggable false
        jniDebuggable false
        renderscriptDebuggable false
        zipAlignEnabled true
        project.ext.react.entryFile "custom.android.js" 
    }
}

然后就能做到react-native run-android --variant=customVariant

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-05-12
    • 2020-09-08
    • 2019-06-01
    • 1970-01-01
    • 2019-12-23
    • 1970-01-01
    相关资源
    最近更新 更多