title: Configuring source map for React Native
body: <p>I'm trying to create a sourcemap for my RN app and this is my first time so please go easy on me.</p>
  
  <p>I found a package <a href="https://github.com/philipshurpik/react-native-source-maps" rel="nofollow noreferrer">react-native-source-maps</a> that does this and I'm trying to understand how to move on with configuring Android side.</p>
  
  <p>In the link mentioned that </p>
  
  <pre><code>def jsBundleMapFile = "${jsBundleFile}.map"
  
  def devEnabled = !targetName.toLowerCase().contains("release")
  if (Os.isFamily(Os.FAMILY_WINDOWS)) {
      commandLine("cmd", "/c", *nodeExecutableAndArgs, "node_modules/react-native/local-cli/cli.js", "bundle", "--platform", "android", "--dev", "${devEnabled}",
              "--reset-cache", "--entry-file", entryFile, "--bundle-output", jsBundleFile, "--assets-dest", resourcesDir, "--sourcemap-output", jsBundleMapFile, *extraPackagerArgs)
  } else {
      commandLine(*nodeExecutableAndArgs, "node_modules/react-native/local-cli/cli.js", "bundle", "--platform", "android", "--dev", "${devEnabled}",
              "--reset-cache", "--entry-file", entryFile, "--bundle-output", jsBundleFile, "--assets-dest", resourcesDir, "--sourcemap-output", jsBundleMapFile, *extraPackagerArgs)
  }
  </code></pre>
  
  <p>And below is the my react.gradle, which I'm not sure which part to paste the code in. The closest relevant part in <code>react.gradle</code> I believe is in below but not sure which part to place the above code and whether it will mess up the current gradle build</p>
  
  <pre><code>// Set up dev mode
    def devEnabled = !(config."devDisabledIn${targetName}"
                  || targetName.toLowerCase().contains("release"))
  
    def extraArgs = extraPackagerArgs;
  
    if (bundleConfig) {
        extraArgs = extraArgs.clone()
        extraArgs.add("--config");
        extraArgs.add(bundleConfig);
    }
  
    if (Os.isFamily(Os.FAMILY_WINDOWS)) {
      commandLine("cmd", "/c", *nodeExecutableAndArgs, cliPath, bundleCommand, "--platform", "android", "--dev", "${devEnabled}",
                      "--reset-cache", "--entry-file", entryFile, "--bundle-output", jsBundleFile, "--assets-dest", resourcesDir, *extraArgs)
              } else {
      commandLine(*nodeExecutableAndArgs, cliPath, bundleCommand, "--platform", "android", "--dev", "${devEnabled}",
                      "--reset-cache", "--entry-file", entryFile, "--bundle-output", jsBundleFile, "--assets-dest", resourcesDir, *extraArgs)
    }
  
    enabled config."bundleIn${targetName}" ||
                  config."bundleIn${variant.buildType.name.capitalize()}" ?:
                  targetName.toLowerCase().contains("release")
  </code></pre>