0

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

4

1 回答 1

0

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 构建中创建不同的变体

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

于 2017-03-21T07:41:00.663 回答