React native 运行-ios 运行-android入口文件

React native run-ios run-android entry file

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

react-native run-android --help 显示了一些选项,但 none 用于指定入口点。然而在 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