Skip to content

Commit

Permalink
React native 0.72.1 and above metro.config.js (#277)
Browse files Browse the repository at this point in the history
* React native 0.72 and above metro.config.js

* updated metro config in readme
  • Loading branch information
adsalihac authored Jul 3, 2023
1 parent 49e2460 commit cc21cc8
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,37 @@ module.exports = (async () => {
})();
```

#### For React Native v0.72.1 or newer

Merge the contents from your project's `metro.config.js` file with this config (create the file if it does not exist already).

`metro.config.js`:

```js
const {getDefaultConfig, mergeConfig} = require('@react-native/metro-config');

const defaultConfig = getDefaultConfig(__dirname);
const {assetExts, sourceExts} = defaultConfig.resolver;

/**
* Metro configuration
* https://facebook.github.io/metro/docs/configuration
*
* @type {import('metro-config').MetroConfig}
*/
const config = {
transformer: {
babelTransformerPath: require.resolve('react-native-svg-transformer'),
},
resolver: {
assetExts: assetExts.filter(ext => ext !== 'svg'),
sourceExts: [...sourceExts, 'svg'],
},
};

module.exports = mergeConfig(defaultConfig, config);
```

### Using TypeScript

If you are using TypeScript, you need to add this to your `declarations.d.ts` file (create one if you don't have one already):
Expand Down

0 comments on commit cc21cc8

Please sign in to comment.