project.json:

1{ 2 "name": "mobile", 3 //... 4 "targets": { 5 //... 6 "bundle-ios": { 7 "executor": "@nx/react-native:bundle", 8 "outputs": ["{projectRoot}/build"], 9 "options": { 10 "entryFile": "src/main.tsx", 11 "platform": "ios", 12 "bundleOutput": "dist/apps/mobile/ios/main.jsbundle" 13 } 14 }, 15 "bundle-android": { 16 "executor": "@nx/react-native:bundle", 17 "options": { 18 "entryFile": "src/main.tsx", 19 "platform": "android", 20 "bundleOutput": "dist/apps/mobile/android/main.jsbundle" 21 } 22 } 23 } 24} 25
Nx 15 and lower use @nrwl/ instead of @nx/
1nx run mobile:bundle-ios 2nx run mobile:bundle-android 3

Examples

The sourcemapOutput option allows you to specify the path of the source map relative to app folder:

1 "bundle-ios": { 2 "executor": "@nx/react-native:bundle", 3 "options": { 4 "entryFile": "src/main.tsx", 5 "platform": "ios", 6 "bundleOutput": "dist/apps/mobile/ios/main.jsbundle", 7 "sourcemapOutput": "../../dist/apps/mobile/ios/main.map", 8 } 9 }, 10 "bundle-android": { 11 "executor": "@nx/react-native:bundle", 12 "options": { 13 "entryFile": "src/main.tsx", 14 "platform": "android", 15 "bundleOutput": "dist/apps/mobile/android/main.jsbundle", 16 "sourcemapOutput": "../../dist/apps/mobile/android/main.map", 17 } 18 } 19
Nx 15 and lower use @nrwl/ instead of @nx/

Options

bundleOutput

Required
string

The output path of the generated files.

entryFile

Required
string

The entry file relative to project root.

platform

pRequired
string
Accepted values: ios, android

Platform to build for.

assetsDest

string

Directory name where to store assets referenced in the bundle.

dev

boolean
Default: true

Generate a development build.

minify

boolean

Allows overriding whether bundle is minified.

maxWorkers

number

The number of workers we should parallelize the transformer on.

resetCache

boolean
Default: false

Removes cached files.

readGlobalCache

boolean
Default: false

Try to fetch transformed JS code from the global cache, if configured.

sourcemapOutput

string

File name where to store the sourcemap file for resulting bundle, ex. /tmp/groups.map.

sourcemapSourcesRoot

string

Path to make sourcemaps sources entries relative to, ex. /root/dir.

sourcemapUseAbsolutePath

boolean
Default: false

Report SourceMapURL using its full path.

transformer

string

Specify a custom transformer to be used.