|
| 1 | +--- |
| 2 | +sidebar_position: 2 |
| 3 | +--- |
| 4 | + |
| 5 | +# Configure Integration |
| 6 | + |
| 7 | +React Native Integrate now supports a configuration file system that allows you to pre-define options for packages to use while implementing their changes. |
| 8 | + |
| 9 | +Most of the time you won't need this because options can be entered through prompts. |
| 10 | + |
| 11 | +However, in some cases complex inputs are needed that can be defined here. |
| 12 | + |
| 13 | +## Configuration File |
| 14 | + |
| 15 | +Create an `integrate.config.js` file in your project root to configure React Native Integrate. The configuration file should export an object that matches the `IntegrateConfig` interface. |
| 16 | + |
| 17 | +```javascript |
| 18 | +// integrate.config.js |
| 19 | +module.exports = { |
| 20 | + plugins: [ |
| 21 | + // Plugin configurations |
| 22 | + ['plugin-with-config', { |
| 23 | + // Plugin specific configuration |
| 24 | + option1: 'value1', |
| 25 | + option2: 'value2' |
| 26 | + }] |
| 27 | + ] |
| 28 | +}; |
| 29 | +``` |
| 30 | + |
| 31 | +## Configuration Options |
| 32 | + |
| 33 | +### Plugins |
| 34 | + |
| 35 | +The `plugins` array allows you to specify which plugins to use and their configurations: |
| 36 | + |
| 37 | +```javascript |
| 38 | +plugins: [ |
| 39 | + ['my-plugin', { |
| 40 | + // Plugin specific configuration options |
| 41 | + config1: 'value1' |
| 42 | + }] |
| 43 | +] |
| 44 | +``` |
| 45 | + |
| 46 | +## Using Configuration in Your Project |
| 47 | + |
| 48 | +The configuration file is automatically loaded when running react-native-integrate commands. The system will: |
| 49 | + |
| 50 | +1. Look for `integrate.config.js` in your project root |
| 51 | +2. Load and validate the configuration |
| 52 | +3. Apply plugin configurations as needed |
| 53 | + |
| 54 | +## Plugin Development |
| 55 | + |
| 56 | +If you're developing an integration using complex options, you can access the configuration in two ways: |
| 57 | + |
| 58 | +1. In JavaScript/TypeScript integration scripts: |
| 59 | +```typescript |
| 60 | +// Access configuration in your integration script |
| 61 | +import { getConfig } from '@react-native-integrate/core'; |
| 62 | +const pluginConfig = getConfig(); |
| 63 | +``` |
| 64 | + |
| 65 | +2. In integration YAML files: |
| 66 | +```yaml |
| 67 | +# Access configuration in your integration.yml |
| 68 | +steps: |
| 69 | + - when: |
| 70 | + config: |
| 71 | + someOption: true |
| 72 | + task: someTask |
| 73 | + # This step runs only when someOption is true in the config |
| 74 | +``` |
| 75 | + |
| 76 | +## Error Handling |
| 77 | + |
| 78 | +If there are issues with your configuration file: |
| 79 | + |
| 80 | +1. Syntax errors will be reported with detailed error messages |
| 81 | +2. Invalid configuration will trigger appropriate warnings |
| 82 | +3. Missing configuration file is handled gracefully - the system will use default settings |
| 83 | + |
| 84 | +## Best Practices |
| 85 | + |
| 86 | +1. Keep your configuration file in the project root |
| 87 | +2. Document plugin-specific configuration options |
| 88 | +3. Version control your configuration file |
| 89 | +4. Use TypeScript for better type checking in your configuration file |
0 commit comments