microsoft/vscode-react-native
Publicmirrored fromhttps://github.com/microsoft/vscode-react-nativeAvailable
doc/customization.md
84lines · modecode
| 1 | # Customization |
| 2 | |
| 3 | There are a few customizations supported by this extension; they can be added to your `.vscode/settings.json` if you need them. |
| 4 | |
| 5 | **NOTE**: To apply changes you made to `.vscode/settings.json`, please, save it and then **restart VS Code instance**. |
| 6 | |
| 7 | ## Specifying custom arguments for `react-native run-*` command |
| 8 | |
| 9 | For using custom run arguments for `react-native run-<platform>`: |
| 10 | * **Note:** This overrides all other configuration parameters. |
| 11 | |
| 12 | ``` |
| 13 | { |
| 14 | "react-native.android.runArguments.simulator": ["--appFolder", "/Users/test/AwesomeProject/android/app", "--deviceId", "emulator-5555"], |
| 15 | "react-native.ios.runArguments.device": ["--project-path", "ios", "--device", "Max's iPhone"], |
| 16 | } |
| 17 | ``` |
| 18 | |
| 19 | * **Note:** You can get the list of installed simulator devices by: |
| 20 | |
| 21 | iOS devices(MacOS only): |
| 22 | |
| 23 | ``` |
| 24 | xcrun simctl list --json devices |
| 25 | ``` |
| 26 | |
| 27 | Android devices: |
| 28 | |
| 29 | ``` |
| 30 | adb devices |
| 31 | ``` |
| 32 | |
| 33 | * **Note:** If you want run application on iOS devices make sure you have `ios-deploy` installed globally. |
| 34 | |
| 35 | ```npm install -g ios-deploy``` |
| 36 | |
| 37 | ## Setting up the react-native packager |
| 38 | |
| 39 | To use a custom port for the `react-native` packager: |
| 40 | |
| 41 | ``` |
| 42 | { |
| 43 | "react-native": { |
| 44 | "packager" : { |
| 45 | "port": portNumber |
| 46 | } |
| 47 | } |
| 48 | } |
| 49 | ``` |
| 50 | |
| 51 | If you change this port, then for iOS device and simulator scenarios you will have to modify the native code files. Instruction [here](https://blog.binoy.io/running-react-native-on-a-different-port-7deb43887cd4).<br> |
| 52 | If you use android, you need to change debug server by: |
| 53 | 1. CTRL+M(CMD+M) in the emulator |
| 54 | 2. Go to Dev Settings |
| 55 | 3. Debug server host for device => enter ‘localhost:\<yourPortNumber\>’. |
| 56 | 4. Reload application (double R) |
| 57 | |
| 58 | * Note that some aspects of React Native hard-code the port to the default as specified in [this issue](https://github.com/facebook/react-native/issues/9145). |
| 59 | |
| 60 | ## Logging |
| 61 | |
| 62 | To expose internal logs to the output, set the following properties: |
| 63 | |
| 64 | ``` |
| 65 | { |
| 66 | "react-native-tools": { |
| 67 | "logLevel": "Trace" |
| 68 | } |
| 69 | } |
| 70 | ``` |
| 71 | |
| 72 | `logLevel` can be `None` (no logs), `Error`, `Warning`, `Info`, `Debug`, `Trace` (all logs). Default is `Info`. |
| 73 | |
| 74 | ## Project structure |
| 75 | |
| 76 | To specify a subfolder in which the react-native project is located, set `react-native-tools.projectRoot`. You can use either an absolute or relative path here: |
| 77 | |
| 78 | ``` |
| 79 | { |
| 80 | "react-native-tools": { |
| 81 | "projectRoot": "./your/react-native/project" |
| 82 | } |
| 83 | } |
| 84 | ``` |
| 85 | |